summaryrefslogtreecommitdiff
path: root/sys
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
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')
-rw-r--r--sys/kern/kern_malloc.c9
-rw-r--r--sys/sys/malloc.h3
2 files changed, 9 insertions, 3 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);
}
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
index 8800cb3d2ed..2b6db69e5ea 100644
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.h,v 1.34 2001/01/04 07:48:40 angelos Exp $ */
+/* $OpenBSD: malloc.h,v 1.35 2001/02/20 23:35:36 csapuntz Exp $ */
/* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */
/*
@@ -54,6 +54,7 @@
*/
#define M_WAITOK 0x0000
#define M_NOWAIT 0x0001
+#define M_ZERO 0x0008
/*
* Types of memory to be allocated