![]() |
Lumiera 0.pre.04
»edit your freedom«
|
Implementation of error-safe wrappers for some notorious C-Lib functions. More...
Go to the source code of this file.
Implementation of error-safe wrappers for some notorious C-Lib functions.
Definition in file safeclib.c.
#include "lib/error.h"#include "lib/safeclib.h"#include <string.h>#include <stdlib.h>#include <pthread.h>#include <stdint.h>#include <nobug.h>Enumerations | |
| enum | lumiera_resource { LUMIERA_RESOURCE_MEMORY , LUMIERA_RESOURCE_END } |
| Resources known to the resource collector. More... | |
| enum | lumiera_resource_try { LUMIERA_RESOURCE_NONE , LUMIERA_RESOURCE_ONE , LUMIERA_RESOURCE_SOME , LUMIERA_RESOURCE_MANY , LUMIERA_RESOURCE_ALL , LUMIERA_RESOURCE_PANIC , LUMIERA_RESOURCE_UNREGISTER } |
| Iteration indicator. More... | |
Functions | |
| LUMIERA_ERROR_DEFINE (NO_MEMORY, "Out of Memory!") | |
| static int | die_no_mem (enum lumiera_resource which, enum lumiera_resource_try *iteration, void *context) |
| void * | lumiera_malloc (size_t size) |
| Allocate memory. | |
| void * | lumiera_calloc (size_t n, size_t size) |
| Allocate cleared memory for an array. | |
| void * | lumiera_realloc (void *ptr, size_t size) |
| Change the size of a memory block. | |
| char * | lumiera_strndup (const char *str, size_t len) |
| Duplicate a C string. | |
| int | lumiera_strncmp (const char *a, const char *b, size_t len) |
| Compare two C strings. | |
| int | lumiera_streq (const char *a, const char *b) |
| check 2 strings for identity. | |
| enum lumiera_resource |
Resources known to the resource collector.
| Enumerator | |
|---|---|
| LUMIERA_RESOURCE_MEMORY | memory blocks, context is a pointer to the size_t required |
| LUMIERA_RESOURCE_END | |
Definition at line 37 of file safeclib.c.
| enum lumiera_resource_try |
Iteration indicator.
Definition at line 74 of file safeclib.c.
| LUMIERA_ERROR_DEFINE | ( | NO_MEMORY | , |
| "Out of Memory!" | |||
| ) |
|
static |
placeholder function in case the resource-collector was not installed
Definition at line 104 of file safeclib.c.
References LUMIERA_DIE.
Referenced by lumiera_calloc(), lumiera_malloc(), lumiera_realloc(), and lumiera_strndup().
Here is the caller graph for this function:| 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 die_no_mem(), LUMIERA_RESOURCE_MEMORY, LUMIERA_RESOURCE_ONE, and NULL.
Referenced by init_exts_globs(), lumiera_config_init(), lumiera_config_lookupentry_new(), lumiera_configentry_new(), lumiera_configitem_new(), lumiera_interfacenode_new(), lumiera_plugin_new(), lumiera_tmpbuf_provide(), TEST(), TEST(), and TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 die_no_mem(), LUMIERA_RESOURCE_MEMORY, LUMIERA_RESOURCE_ONE, and NULL.
Referenced by lumiera_tmpbuf_provide(), and push_dependency().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 die_no_mem(), LUMIERA_RESOURCE_MEMORY, LUMIERA_RESOURCE_ONE, and NULL.
Referenced by push_dependency().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 die_no_mem(), LUMIERA_RESOURCE_MEMORY, LUMIERA_RESOURCE_ONE, and NULL.
Referenced by lumiera_config_lookupentry_init(), lumiera_configitem_parse(), and lumiera_plugin_new().
Here is the call graph for this function:
Here is the caller graph for this function:| 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_streq().
Here is the caller graph for this function:| 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 TEST().
Here is the call graph for this function:
Here is the caller graph for this function: