summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-14 05:19:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-14 05:19:34 +0000
commit0b1e65db7b3fc3c7d5572cc348ef03a53fcb56e7 (patch)
tree47642d0f71ff1a92476603e9773e56b75a4b1b61 /sys
parent94e7bd1c1ec76c7e08243e8e674c3ce5395b1de8 (diff)
from netbsd; limfree()
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_exit.c5
-rw-r--r--sys/kern/kern_resource.c24
2 files changed, 19 insertions, 10 deletions
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);
}