This repository has been archived on 2017-07-22. You can view files and clone it, but cannot push or open issues/pull-requests.
jlsampler/jl_mem.h

41 lines
979 B
C

/*****************************************************************************
* VERSION: 1.05
* 2015-08-28
*
* Memory allocation functions.
*****************************************************************************/
#ifndef JLLIB_MEM_HEADER_
#define JLLIB_MEM_HEADER_
#include <stdlib.h>
void *jl_malloc_chk(size_t size, char *file, int line);
void jl_free_chk(void *ptr);
void *jl_malloc_exit(size_t size);
void jl_mem_print_leaks(void);
void jl_mem_leak_check_init();
#ifdef JL_LEAK_CHECK
#define jl_malloc_exit(s) jl_malloc_chk(s, __FILE__, __LINE__)
#define jl_malloc(s) jl_malloc_chk(s, __FILE__, __LINE__)
#define jl_free(p) jl_free_chk(p)
#define JL_LEAK_CHECK_INIT jl_mem_leak_check_init()
#else // JL_LEAK_CHECK
#define JL_LEAK_CHECK_INIT
#define jl_malloc(s) malloc(s)
#define jl_calloc(n, s) calloc(n, s)
#define jl_realloc(p, s) realloc(p, s)
#define jl_free(p) free(p)
#endif // JL_LEAK_CHECK
#endif // JLLIB_MEM_HEADER_