From 3db63c95b3b5cc8853fa6a3a19afe34a8ba20dd2 Mon Sep 17 00:00:00 2001
From: gdamore malloc.
If memory cannot be allocated for any reason, then NULL will be returned.
-Applications that experience this should treat this like NNG_ENOMEM.
Memory returned by nng_alloc should be freed when no longer needed using nng_free.
NNG_ENOMEM.
+Memory returned by nng_alloc should be freed when no longer needed using nng_free.
@@ -270,30 +270,35 @@ other unpredictable behavior.
void nng_free(void *ptr, size_t size);
-The nng_free function deallocates memory previously allocated by nng_alloc.
The nng_free function deallocates memory previously allocated by nng_alloc.
The size argument must exactly match the size argument that was supplied to
-nng_alloc when the memory was allocated.
nng_alloc when the memory was allocated.
char *nng_strdup(const char *src);
The nng_strdup duplicates the string src and returns it.
This is logically equivalent to using nng_alloc
+
This is logically equivalent to using nng_alloc
to allocate a region of memory of strlen(s) + 1 bytes, and then
using strcpy to copy the string into the destination before
returning it.
The returned string should be deallocated with
-nng_strfree, or may be deallocated using the
-nng_free using the length of the returned string plus
+nng_strfree, or may be deallocated using the
+nng_free using the length of the returned string plus
one (for the NUL terminating byte).
void nng_strfree(char *str);
The nng_strfree function is a convenience function that
-can be used to deallocate strings allocated with nng_strdup.
nng_strdup.
It is effectively the same as nng_free(strlen(str) + 1).