aboutsummaryrefslogtreecommitdiff
path: root/src/core/platform.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-07-20 13:42:13 -0700
committerGarrett D'Amore <garrett@damore.org>2018-07-24 07:57:39 -0700
commitccc24a8e508131a2226474642a038baaa2cbcc8c (patch)
tree7029f7668fe3e1a9899da57bf6c1e60e0394bacb /src/core/platform.h
parent9b9526e4a643d36d9c66f2254f00df7298e5562f (diff)
downloadnng-ccc24a8e508131a2226474642a038baaa2cbcc8c.tar.gz
nng-ccc24a8e508131a2226474642a038baaa2cbcc8c.tar.bz2
nng-ccc24a8e508131a2226474642a038baaa2cbcc8c.zip
fixes #605 NNI_ALLOC_STRUCT/NNI_ALLOC_STRUCTS should zero memory
Diffstat (limited to 'src/core/platform.h')
-rw-r--r--src/core/platform.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/platform.h b/src/core/platform.h
index 2ae0fd0b..70f4e9ef 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -69,10 +69,15 @@ extern const char *nni_plat_strerror(int);
// to return NULL if memory cannot be allocated.
extern void *nni_alloc(size_t);
-// nni_free frees memory allocated with nni_alloc. It takes a size because
-// some allocators do not track size, or can operate more efficiently if
-// the size is provided with the free call. Examples of this are slab
-// allocators like this found in Solaris/illumos (see libumem or kmem).
+// nni_zalloc is just like nni_alloc, but ensures that memory is
+// initialized to zero. It is a separate function because some platforms
+// can use a more efficient zero-based allocation.
+extern void *nni_zalloc(size_t);
+
+// nni_free frees memory allocated with nni_alloc or nni_zalloc. It takes
+// a size because some allocators do not track size, or can operate more
+// efficiently if the size is provided with the free call. Examples of this
+// are slab allocators like this found in Solaris/illumos (see libumem).
// This routine does nothing if supplied with a NULL pointer and zero size.
// Most implementations can just call free() here.
extern void nni_free(void *, size_t);