aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-14 23:20:52 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-14 23:20:52 +0100
commitd932648b0324288aaa4bb14a08a8d1f1be044036 (patch)
treebb0d9c413b7c0b4f2e73b1f0dca520a3711fca77
parentm malloc.c (diff)
downloadslibc-d932648b0324288aaa4bb14a08a8d1f1be044036.tar.gz
slibc-d932648b0324288aaa4bb14a08a8d1f1be044036.tar.bz2
slibc-d932648b0324288aaa4bb14a08a8d1f1be044036.tar.xz
m doc mallocz
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--include/malloc.h4
-rw-r--r--src/malloc.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/include/malloc.h b/include/malloc.h
index f4a910a..d6f0be5 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -77,6 +77,10 @@ void* calloc(size_t, size_t)
/**
* Variant of `malloc` that conditionally clears the allocation with zeroes.
*
+ * `mallocz(size, clear)` is equivalent to
+ * both `(clear ? zalloc : malloc)(size)`
+ * and `(clear ? calloc(1, size) : malloc(size))`.
+ *
* This is a Plan 9 from Bell Labs extension.
*
* @param size The size of the allocation.
diff --git a/src/malloc.c b/src/malloc.c
index 538f338..28824e9 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -129,6 +129,10 @@ void* calloc(size_t elem_count, size_t elem_size)
/**
* Variant of `malloc` that conditionally clears the allocation with zeroes.
*
+ * `mallocz(size, clear)` is equivalent to
+ * both `(clear ? zalloc : malloc)(size)`
+ * and `(clear ? calloc(1, size) : malloc(size))`.
+ *
* This is a Plan 9 from Bell Labs extension.
*
* @param size The size of the allocation.