From: deraadt Date: Thu, 14 Dec 1995 05:19:32 +0000 (+0000) Subject: from netbsd; limfree() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4862cb716715ec62bd4a14b04edfdcbb234bf174;p=openbsd from netbsd; limfree() --- diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 466dd88ddc5..27a12beee9a 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.33 1995/10/07 06:28:13 mycroft Exp $ */ +/* $NetBSD: kern_exit.c,v 1.34 1995/12/09 04:09:32 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -253,8 +253,7 @@ exit1(p, rv) * Other substructures are freed from wait(). */ curproc = NULL; - if (--p->p_limit->p_refcnt == 0) - FREE(p->p_limit, M_SUBPROC); + limfree(p->p_limit); /* * Finally, call machine-dependent code to release the remaining diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index d3a956b5d72..7f4e56a16ae 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.31 1995/10/07 06:28:23 mycroft Exp $ */ +/* $NetBSD: kern_resource.c,v 1.32 1995/12/09 04:09:34 mycroft Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -435,13 +435,23 @@ struct plimit * limcopy(lim) struct plimit *lim; { - register struct plimit *copy; + register struct plimit *newlim; - MALLOC(copy, struct plimit *, sizeof(struct plimit), + MALLOC(newlim, struct plimit *, sizeof(struct plimit), M_SUBPROC, M_WAITOK); - bcopy(lim->pl_rlimit, copy->pl_rlimit, + bcopy(lim->pl_rlimit, newlim->pl_rlimit, sizeof(struct rlimit) * RLIM_NLIMITS); - copy->p_lflags = 0; - copy->p_refcnt = 1; - return (copy); + newlim->p_lflags = 0; + newlim->p_refcnt = 1; + return (newlim); +} + +void +limfree(lim) + struct plimit *lim; +{ + + if (--lim->p_refcnt > 0) + return; + FREE(lim, M_SUBPROC); }