22 #ifndef __CCL_MEMORY_H__
23 # define __CCL_MEMORY_H__
33 typedef void ccl_memory_exhaustion_handler (
void *data);
41 ccl_memory_add_exhaustion_handler (ccl_memory_exhaustion_handler *hdl,
45 ccl_memory_del_exhaustion_handler (ccl_memory_exhaustion_handler *hdl,
53 # define ccl_malloc(sz) ccl_debug_malloc(sz,__FILE__,__LINE__)
54 # define ccl_calloc(nb,sz) ccl_debug_calloc(nb,sz,__FILE__,__LINE__)
55 # define ccl_realloc(p,sz) ccl_debug_realloc(p,sz,__FILE__,__LINE__)
56 # define ccl_free(p) ccl_debug_free(p,__FILE__,__LINE__)
59 # define ccl_malloc(sz) ccl_real_malloc(sz)
60 # define ccl_calloc(nb,sz) ccl_real_calloc(nb,sz)
61 # define ccl_realloc(p,sz) ccl_real_realloc(p,sz)
62 # define ccl_free(p) ccl_real_free(p)
65 # define CCL_DECLARE_DELETE_PROC(_id) extern void _id (void *p)
66 # define CCL_DEFINE_DELETE_PROC(_id) void _id (void *p) { ccl_delete (p); }
71 # define ccl_new_array(_type_,_sz_) \
72 ((_type_ *)ccl_calloc (_sz_, sizeof(_type_)))
78 # define ccl_new(_type_) ccl_new_array (_type_, 1)
83 # define ccl_delete(_ptr_) ccl_free (_ptr_)
88 # define ccl_zdelete(_del,_ptr_) \
91 if ((_ptr_) != NULL) \
99 # define ccl_memzero(_p,_size) ccl_memset (_p, 0, _size)
105 # define ccl_memset(_p,_c,_size) memset (_p, _c, _size)
110 # define ccl_memcpy(_dst,_src,_size) memcpy (_dst, _src, _size)
116 # define ccl_memcmp(_p1,_p2,_size) memcmp (_p1, _p2, _size)
119 ccl_real_malloc (
size_t size);
121 ccl_real_free (
void *ptr);
123 ccl_real_realloc (
void *ptr,
size_t size);
125 ccl_real_calloc (
size_t nb_el,
size_t el_size);
128 ccl_debug_malloc (
size_t size,
const char *filename,
int line);
130 ccl_debug_free (
void *ptr,
const char *filename,
int line);
132 ccl_debug_realloc (
void *ptr,
size_t size,
const char *filename,
int line);
134 ccl_debug_calloc (
size_t nb_el,
size_t el_size,
const char *filename,
137 ccl_debug_log_statistics_per_module (
void);
Some useful and common macros.
#define CCL_DECLARE_EXCEPTION(exc, super)
Macro-function used to declare an exception exc.