SPRAAK
|
Dynamic memory management & checking. More...
Data Structures | |
struct | SprMPool |
Macros | |
#define | SPR_MPOOL_CHUNK_SZ |
#define | SPR_MPOOL_INITIALIZER(type, next_el) |
#define | SPR_MPOOL_INIT(mpool, type, next_el) |
Functions | |
void * | spr_free (void *ptr, const SprMsgId *routine, const char *item) |
void * | spr_malloc (size_t size, const SprMsgId *routine, const char *item) |
void * | spr_realloc (void *ptr, size_t size, const SprMsgId *routine, const char *item) |
size_t | spr_dynmem_item_cnt (void) |
size_t | spr_dynmem_byte_cnt (void) |
unsigned int | spr_dynmem_check (SprMsgId *routine, const char *id) |
Check if the heap is corrupted. This routine is not mult-threading safe. More... | |
void | spr_hexdump2buf (char *dst, const void *data, size_t size) |
int | spr_dynmem_dump (SprStream *fd) |
Dump the data that is still allocated to file fd. This routine is not mult-threading safe. More... | |
char * | spr_strdup (const char *src, const SprMsgId *routine, const char *item) |
char * | spr_strndup (const char *src, size_t size, const SprMsgId *routine, const char *item) |
char * | spr_strcpy (char **restrict dst, const char *restrict src) |
char * | spr_strcat (char *restrict str1, const char *restrict str2, int *restrict str1_len, int str2_len, int *restrict alen) |
char * | spr_dynstr2alloc (SprDynStr str) |
SprDynStr | spr_dynstr_free (SprDynStr str, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_alloc (size_t size, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_realloc (SprDynStr str, size_t size, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_enlarge (SprDynStr str, size_t size, const SprMsgId *routine, const char *item) |
size_t | spr_dynstr_maxlen (SprDynStr str) |
SprDynStr | spr_dynstr_cpy (SprDynStr dst, const char *src) |
SprDynStr | spr_dynstr_ncpy (SprDynStr dst, const char *src, size_t src_len) |
SprDynStr | spr_dynstr_dup (const char *src, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_ndup (const char *src, size_t src_len) |
SprDynStr | spr_dynstr_cat (SprDynStr restrict str1, const char *restrict str2, int *restrict str1_len, int str2_len) |
const char * | spr_str_nonull_ (const char *str) |
const char * | spr_str_nonull (const char *str, const char *str_null) |
const char * | spr_str_no_empty (const char *str, const char *str_empty) |
size_t | spr_dynmem_pool_count_alloc (const SprMPool *mpool) |
size_t | spr_dynmem_pool_count_free (const SprMPool *mpool) |
size_t | spr_dynmem_pool_free (SprMPool *mpool, SprMsgId *routine) |
void * | spr_dynmem_pool_enlarge (SprMPool *mpool) |
void | spr_dynmem_cfg (int mode) |
Dynamic memory management & checking.
This module provides routines for dynamic memory management (allocation and release) with error reporting and configurable checks for memory leaks.
The routines fall in three groups:
The system also allows turning on additional accounting and checking. This should allow easy and fast detection of memory leaks, double free's, and simple buffer overrun errors. The additional accounting and checking can be enabled by either using the '–check_dynmem <lvl>' option when calling a program or by setting the 'SPR_DYNMEM_CHECK' environment variable. See spr_dynmem_cfg() for the different modes one can select.