Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Portable and safe wrappers around some C-Lib functions.
Definition in file safeclib.h.
Functions | |
void * | lumiera_calloc (size_t n, size_t size) |
Allocate cleared memory for an array. More... | |
LUMIERA_ERROR_DECLARE (NO_MEMORY) | |
static void | lumiera_free (void *mem) |
Free previously allocated memory. More... | |
void * | lumiera_malloc (size_t sz) |
Allocate memory. More... | |
void * | lumiera_realloc (void *ptr, size_t size) |
Change the size of a memory block. More... | |
void | lumiera_safeclib_set_resourcecollector (void *hook) |
Install the resourcecollector run hook. More... | |
int | lumiera_streq (const char *a, const char *b) |
check 2 strings for identity. More... | |
int | lumiera_strncmp (const char *a, const char *b, size_t len) |
Compare two C strings. More... | |
char * | lumiera_strndup (const char *str, size_t len) |
Duplicate a C string. More... | |
void lumiera_safeclib_set_resourcecollector | ( | void * | hook | ) |
Install the resourcecollector run hook.
The resourcecollectr must be hooked into the safeclib at bootup after it got initialised and removed from it before shut down. Without resourcecollector failed allocations will abort().
hook | pointer to the resourcecollector_run function, must be of type lumiera_resourcecollector_run_fn but we don't want a dependency on vault in this header |
void* lumiera_malloc | ( | size_t | sz | ) |
Allocate memory.
always succeeds or dies
size | memory to be allocated |
Definition at line 113 of file safeclib.c.
References LUMIERA_RESOURCE_ONE.
Referenced by lumiera_plugin_new().
void* lumiera_calloc | ( | size_t | n, |
size_t | size | ||
) |
Allocate cleared memory for an array.
always succeeds or dies
n | number of elements |
size | memory to be allocated |
Definition at line 130 of file safeclib.c.
References LUMIERA_RESOURCE_ONE.
void* lumiera_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Change the size of a memory block.
ptr | pointer to the old memory block obtained by lumiera_malloc or lumiera_calloc |
size | new size of the block |
Definition at line 149 of file safeclib.c.
References LUMIERA_RESOURCE_ONE.
|
inlinestatic |
Free previously allocated memory.
mem | pointer to the memory block obtained by lumiera_malloc or lumiera_calloc |
Definition at line 73 of file safeclib.h.
References lumiera_streq(), lumiera_strncmp(), and lumiera_strndup().
char* lumiera_strndup | ( | const char * | str, |
size_t | len | ||
) |
Duplicate a C string.
always succeeds or dies
str | string to be copied |
len | maximal length to be copied |
Definition at line 166 of file safeclib.c.
References LUMIERA_RESOURCE_ONE.
Referenced by lumiera_free(), and lumiera_plugin_new().
int lumiera_strncmp | ( | const char * | a, |
const char * | b, | ||
size_t | len | ||
) |
Compare two C strings.
Handles NULL pointers as "", shortcut for same addresses
a | first string for comparsion |
b | second string for comparsion |
len | maximal length for the comparsion |
Definition at line 184 of file safeclib.c.
Referenced by lumiera_free(), and lumiera_streq().
int lumiera_streq | ( | const char * | a, |
const char * | b | ||
) |
check 2 strings for identity.
a | first string for comparsion |
b | second string for comparsion |
Definition at line 191 of file safeclib.c.
References lumiera_strncmp().
Referenced by lumiera_free().