Memory allocation


The Memory allocation module introduces a number of wrappers to basic memory management functions which allows to change the underlying memory allocator in a way that is transparent to the applications built on LibU. It is sufficient for an application to only use u_malloc/u_free and friends (which also include u_memdup, u_strndup and u_strdup from the Miscellaneous module) when carrying out memory allocation and deallocation operations. In case it'd be needed to change the underlying memory management facility with a custom one a call to u_memory_set_malloc and co. would be enough to fix it up, provided that the new memory management system has ISO C-like malloc(3) interfaces.


void u_memory_set_malloc (void *(*f_malloc)(size_t))
 Set malloc(3) replacement.
void u_memory_set_calloc (void *(*f_calloc)(size_t, size_t))
 Set calloc(3) replacement.
void u_memory_set_realloc (void *(*f_realloc)(void *, size_t))
 Set realloc(3) replacement.
void u_memory_set_free (void(*f_free)(void *))
 Set free(3) replacement.
void * u_malloc (size_t sz)
 Wrapper for malloc-like function.
void * u_calloc (size_t cnt, size_t sz)
 Wrapper for calloc-like function.
void * u_zalloc (size_t sz)
 Alloc a contiguous region of sz bytes and zero-fill it.
void * u_realloc (void *ptr, size_t sz)
 Wrapper for realloc-like function.
void u_free (void *ptr)
 Wrapper for free-like function, sanity checks the supplied pointer.

© 2005-2012 - KoanLogic S.r.l. - All rights reserved