diff options
author | phk <phk@FreeBSD.org> | 2000-10-20 17:54:55 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-10-20 17:54:55 +0000 |
commit | 55e86a81b7d5c5c9b30129c8436b626fd7e5747f (patch) | |
tree | 6ad4f5870ab0512eeafbd1dbebf12bb8ea3bcad0 /sys/kern | |
parent | 02af04a1fbe478ec704796653724f46c704b4b65 (diff) | |
download | FreeBSD-src-55e86a81b7d5c5c9b30129c8436b626fd7e5747f.zip FreeBSD-src-55e86a81b7d5c5c9b30129c8436b626fd7e5747f.tar.gz |
Introduce the M_ZERO flag to malloc(9)
Instead of:
foo = malloc(sizeof(foo), M_WAIT);
bzero(foo, sizeof(foo));
You can now (and please do) use:
foo = malloc(sizeof(foo), M_WAIT | M_ZERO);
In the future this will enable us to do idle-time pre-zeroing of
malloc-space.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_malloc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index a2e77fd..f268be6 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -280,6 +280,9 @@ out: ksp->ks_maxused = ksp->ks_memuse; splx(s); mtx_exit(&malloc_mtx, MTX_DEF); + /* XXX: Do idle pre-zeroing. */ + if (va != NULL && (flags & M_ZERO)) + bzero(va, size); return ((void *) va); } |