Routines for safe memory allocation based on using.
More...
Macros | |
| #define | nodecx_malloc |
| #define | nodecx_calloc |
| #define | nodecx_realloc |
| #define | nodecx_free |
| #define | nodec_malloc |
| #define | nodec_calloc |
| #define | nodec_realloc |
| #define | nodec_free |
| #define | nodecx_alloc(tp) |
| #define | nodecx_zero_alloc(tp) |
| #define | nodec_alloc(tp) |
| Allocate memory for a type. More... | |
| #define | nodec_alloc_n(n, tp) |
| #define | nodec_zero_alloc_n(n, tp) |
| #define | nodec_zero_alloc(tp) |
| #define | nodec_realloc_n(p, n, tp) |
| #define | using_free(name) |
| Use a pointer in a scope and free afterwards. More... | |
| #define | using_alloc(tp, name) |
| Allocate and use a pointer in a scope and free afterwards. More... | |
| #define | using_alloc_n(n, tp, name) |
| #define | using_zero_alloc_n(n, tp, name) |
| #define | using_zero_alloc(tp, name) |
| #define | nodec_zero(tp, ptr) |
Functions | |
| void | nodec_register_malloc (lh_mallocfun *_malloc, lh_callocfun *_calloc, lh_reallocfun *_realloc, lh_freefun *_free) |
| void | nodec_check_memory () |
| void * | check_nonnull (void *p) |
| void * | _nodecx_malloc (size_t size) |
| void * | _nodecx_calloc (size_t count, size_t size) |
| void * | _nodecx_realloc (void *p, size_t newsize) |
| void * | _nodec_malloc (size_t size) |
| void * | _nodec_calloc (size_t count, size_t size) |
| void * | _nodec_realloc (void *p, size_t newsize) |
| void | _nodec_free (const void *p) |
| void | nodec_freev (lh_value p) |
| char * | nodec_strdup (const char *s) |
| char * | nodec_strndup (const char *s, size_t max) |
| const void * | nodec_memmem (const void *src, size_t src_len, const void *pat, size_t pat_len) |
| int | nodec_strnicmp (const char *s, const char *t, size_t n) |
| int | nodec_stricmp (const char *s, const char *t) |
| uv_errno_t | nodec_strncpy (char *dest, size_t destsz, const char *src, size_t count) |
Routines for safe memory allocation based on using.
These raise an exception on failure and always free even if exceptions are raised. The code :
will safely allocate a mystruct_t* to name which can be used inside ... and will be deallocated safely if an exception is thrown or when exiting the block scope.
| #define nodec_alloc | ( | tp | ) |
Allocate memory for a type.
| tp | The type to allocate memory for. Example |
| #define using_alloc | ( | tp, | |
| name | |||
| ) |
Allocate and use a pointer in a scope and free afterwards.
Always frees the pointer, even if an exception is thrown.
| tp | The type of value to allocate. |
| name | The name of the tp*. Equivalent to: |
| #define using_free | ( | name | ) |
Use a pointer in a scope and free afterwards.
Always frees the pointer, even if an exception is thrown.
| name | The name of the void*. |