EXUDE(3)

NAME
exude - memory debugger

SYNOPSIS
#include <exude.h>
int
e_asprintf(char **ret, const char *fmt, ...);
void *
e_calloc(size_t nmemb, size_t size);
void
e_check_memory(void);
void
e_free(void **ptr);
void *
e_malloc(size_t size);
void *
e_realloc(void *ptr, size_t size);
char *
e_strdup(const char *s);
int
e_vasprintf(char **ret, const char *format, va_list ap);
void
exude_version(int *major, int *minor, int *patch);
void
exude_enable(uint64_t debug_bit);
void
exude_disable(void);
void
exude_enable_threads(void);
void
exude_cleanup(void);

DESCRIPTION
exude is a memory debugging library that aids in finding memory leaks.

exude_enable() and exude_disable() are routines to enable and disable debugging respectively. Debugging is disabled by default. The debug_mask parameter to exude_enable() determines the clog(3) debug mask that will be used by debugging functions. The macro EXUDE_DBG_ALWAYS may be used to log unconditionally. If exude is to be used in a threaded application then exude_enable_threads() should be called before using library functions. exude_cleanup() may be called to free any resources if the library is no longer needed.

e_asprintf(), e_calloc(), e_malloc(), e_realloc(), e_strdup(), and e_vasprintf() are all wrapper functions to the standard system functions and are used in the same way.

e_free() is a wrapper function around free(3), but takes a pointer to a variable instead. The variable will be set to NULL to remove references to the freed memory.

e_check_memory() can be called to verify that all exude tracked memory allocations have been freed. This function will abort (coredump) if not all memory has been freed. If clog_init(3) and clog_set_flags(3) have been called, e_check_memory() will show all of the callers that allocated memory which have not been freed.

exude_version() sets the values of major, minor, and patch to their respected values.

EXAMPLES
The following will point ptr to an allocated area of memory containing the NUL-terminated string "foobar", then free the memory:

    char *ptr;
    exude_enable();
    ptr = e_strdup("foobar");
    e_free(&str);

The following use of e_check_memory() will output memory allocation to stderr and abort due to all memory not being freed:

    clog_init(1);
    clog_set_flags(CLOG_F_ENABLE | CLOG_F_STDERR);
    exude_enable();
    p = e_malloc(len + 1);
    e_check_memory();

SEE ALSO
asprintf(3) calloc(3) clog_init(3) clog_set_flags(3) free(3) malloc(3) realloc(3) strdup(3) vasprintf(3)

HISTORY
-nosplit exude was written by Marco Peereboom <marco@peereboom.us>