squareball
0.2.0.53-dd5b
A general-purpose library for C99
|
Memory allocation related helpers. More...
#include <stddef.h>
Go to the source code of this file.
typedef void(* | sb_free_func_t) (void *ptr) |
void * | sb_malloc (size_t size) |
void * | sb_realloc (void *ptr, size_t size) |
Memory allocation related helpers.
typedef void(* sb_free_func_t) (void *ptr) |
Function signature for helpers that are used to free memory of custom types.
Each function should receive the pointer, and free the memory used by the type as needed.
The sb_slist_free_full function is an example of usage of these helper functions.
ptr | An dinamically allocated pointer to be free'd. |
void* sb_malloc | ( | size_t | size | ) |
Safe malloc replacement function. This function validates the output of the libc's malloc call and aborts if needed. See malloc(3) for details.
size | Number of bytes to be allocated. |
void* sb_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Safe realloc replacement function. This function validates the output of the libc's realloc call and aborts if needed. See realloc(3) for details.
ptr | A pointer to be resized. |
size | New number of bytes allocated after reallocation. |