|
YAZ 5.35.1
|
Implements malloc interface. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <yaz/log.h>#include <yaz/xmalloc.h>Go to the source code of this file.
Macros | |
| #define | TRACE_XMALLOC 1 |
| #define | MALLOC_SIZE_MAX ((size_t)(-1) / 4) |
| #define | xrealloc_d(o, x, f, l) realloc(o, x) |
| #define | xmalloc_d(x, f, l) malloc(x) |
| #define | xcalloc_d(x, y, f, l) calloc(x,y) |
| #define | xfree_d(x, f, l) free(x) |
| #define | xmalloc_trav_d(f, l) |
Functions | |
| void | xmalloc_trav_f (const char *s, const char *file, int line) |
| logs all xmalloc buffers | |
| void | xmalloc_fatal (size_t size) |
| void * | xrealloc_f (void *o, size_t size, const char *file, int line) |
| realloc | |
| void * | xmalloc_f (size_t size, const char *file, int line) |
| malloc | |
| void * | xcalloc_f (size_t nmemb, size_t size, const char *file, int line) |
| calloc | |
| char * | xstrdup_f (const char *s, const char *file, int line) |
| strdup | |
| void | xfree_f (void *p, const char *file, int line) |
| free | |
| char * | xstrndup_f (const char *s, size_t n, const char *file, int line) |
| strndup | |
Variables | |
| static int | log_level = 0 |
| static int | log_level_initialized = 0 |
Implements malloc interface.
Definition in file xmalloc.c.
| void * xcalloc_f | ( | size_t | nmemb, |
| size_t | size, | ||
| const char * | file, | ||
| int | line | ||
| ) |
calloc
| nmemb | number of members |
| size | size of member |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xcalloc in which file and line are set automatically.
Definition at line 302 of file xmalloc.c.
References log_level, log_level_initialized, xcalloc_d, xmalloc_fatal(), yaz_log(), yaz_log_module_level(), and YLOG_FATAL.
| void xfree_f | ( | void * | p, |
| const char * | file, | ||
| int | line | ||
| ) |
| void * xmalloc_f | ( | size_t | size, |
| const char * | file, | ||
| int | line | ||
| ) |
malloc
| size | size of buffer to be allocated |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xmalloc in which file and line are set automatically.
Definition at line 279 of file xmalloc.c.
References log_level, log_level_initialized, xmalloc_d, xmalloc_fatal(), yaz_log(), yaz_log_module_level(), and YLOG_FATAL.
Referenced by xstrndup_f().
| void xmalloc_fatal | ( | size_t | size | ) |
Definition at line 251 of file xmalloc.c.
References MALLOC_SIZE_MAX.
Referenced by xcalloc_f(), xmalloc_f(), and xrealloc_f().
| void xmalloc_trav_f | ( | const char * | s, |
| const char * | file, | ||
| int | line | ||
| ) |
logs all xmalloc buffers
| s | not used |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xmalloc_trav in which file and line are set automatically. Only if TRACE_XMALLOC > 1 this function does any real work!
Definition at line 240 of file xmalloc.c.
References log_level, log_level_initialized, xmalloc_trav_d, and yaz_log_module_level().
| void * xrealloc_f | ( | void * | o, |
| size_t | size, | ||
| const char * | file, | ||
| int | line | ||
| ) |
realloc
| o | buffer to be reallocated |
| size | size of buffer to be allocated |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xrealloc in which file and line are set automatically.
Definition at line 257 of file xmalloc.c.
References log_level, log_level_initialized, xmalloc_fatal(), xrealloc_d, yaz_log(), yaz_log_module_level(), and YLOG_FATAL.
| char * xstrdup_f | ( | const char * | p, |
| const char * | file, | ||
| int | line | ||
| ) |
strdup
| p | string to be cloned |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xstrdup in which file and line are set automatically.
Definition at line 324 of file xmalloc.c.
References log_level, log_level_initialized, xmalloc_d, yaz_log(), and yaz_log_module_level().
Referenced by xstrndup_f().
| char * xstrndup_f | ( | const char * | p, |
| size_t | n, | ||
| const char * | file, | ||
| int | line | ||
| ) |
strndup
| p | string to be cloned |
| n | max size of resulting string (excluding 0) |
| file | fname location of use |
| line | line location of use |
This function is invoked via macro xstrndup in which file and line are set automatically.
Definition at line 350 of file xmalloc.c.
References xmalloc_f(), and xstrdup_f().
|
static |
Definition at line 29 of file xmalloc.c.
Referenced by xcalloc_f(), xfree_f(), xmalloc_f(), xmalloc_trav_f(), xrealloc_f(), and xstrdup_f().
|
static |
Definition at line 30 of file xmalloc.c.
Referenced by xcalloc_f(), xmalloc_f(), xmalloc_trav_f(), xrealloc_f(), and xstrdup_f().