summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>2001-02-20 23:35:37 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>2001-02-20 23:35:37 +0000
commit44f3af757835f18033deec7834c749be3bb92d2e (patch)
tree449eaba55a9f319a796d61b739235889e4b4312f /sys/kern
parent4922fc12401cd9ffa9d5403de218efddc61cbd19 (diff)
Add M_ZERO option to malloc. Causes malloc to return a zero'ed buffer.
Used by the new soft updates code
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_malloc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 92c0f1a6ab5..d52ea29ef5e 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.22 2001/01/04 07:49:24 angelos Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.23 2001/02/20 23:35:35 csapuntz Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -135,8 +135,11 @@ malloc(size, type, flags)
#endif
#ifdef MALLOC_DEBUG
- if (debug_malloc(size, type, flags, (void **)&va))
+ if (debug_malloc(size, type, flags, (void **)&va)) {
+ if ((flags & M_ZERO) && va != NULL)
+ bzero(va, size);
return ((void *) va);
+ }
#endif
indx = BUCKETINDX(size);
@@ -309,6 +312,8 @@ out:
out:
#endif
splx(s);
+ if ((flags & M_ZERO) && va != NULL)
+ bzero(va, size);
return ((void *) va);
}