19#define _XOPEN_SOURCE 500
31 const char* CompilDate,
32 const char* CompilTime,
36 void* l_tmp =
malloc(Size);
37 if (NULL == l_tmp)
return (l_tmp);
40#pragma GCC diagnostic push
43#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
49 if (0!=
memtrack_addblock( l_tmp, Size, File,Line,CompilDate,CompilTime,Function)) {
50#pragma GCC diagnostic pop
64 const char* CompilDate,
65 const char* CompilTime,
88 const char* CompilDate,
89 const char* CompilTime,
97 File,Line,CompilDate,CompilTime,Function);
102 memset((
char*)l_tmp, 0, NMemb*Size);
113 const char* CompilDate,
114 const char* CompilTime,
136 File,Line,CompilDate,CompilTime,Function
145 File,Line,CompilDate,CompilTime,Function
150 if (NULL == newblk)
return (newblk);
155 memcpy(newblk,(
char*)Ptr,(l_oldsize<Size?l_oldsize:Size));
160 File,Line,CompilDate,CompilTime,Function
163 return (
void*) newblk;
172 const char* CompilDate,
173 const char* CompilTime,
184 if (NULL != l_newblk)
188 File,Line,CompilDate,CompilTime,Function
201 const char* p_Format,
204 const char *CompilDate,
205 const char *CompilTime,
const char *Function,
216 va_start (l_ap, Function);
220 l_returncode = vasprintf(p_Ptr, p_Format, l_ap);
225 if (-1 != l_returncode)
229 File,Line,CompilDate,CompilTime,Function
void * dbg_malloc(const size_t Size, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function)
Malloc compatible standard allocation.
void * dbg_calloc(const size_t NMemb, const size_t Size, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function)
Allocate a table of item from the size of each and number.
void * dbg_realloc(void *Ptr, const size_t Size, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function)
Resize an already allocated and tracked block.
int dbg_asprintf(char **p_Ptr, const char *p_Format, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function,...)
Build a formatted string with allocation.
void dbg_free(void *Ptr, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function)
Free compatible standard memory release.
char * dbg_strdup(const char *Ptr, const char *File, const int Line, const char *CompilDate, const char *CompilTime, const char *Function)
String duplication with allocation.
Memory leak tracker header.
#define malloc(size)
Same syntaxt and same behavior than regular malloc function, with memory leaks tracking.
#define strdup(chaine)
Same syntaxt and same behavior than regular strdup function, with memory leaks tracking.
#define free(ptr)
Same syntaxt and same behavior than regular free function, with memory leaks tracking.
size_t(* memtrack_getblocksize)(const void *p_Ptr)
Functor to get size of a specific memory block.
unsigned int(* memtrack_delblock)(const void *p_Ptr, const char *p_File, const int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function)
Functor to unregister an allocated memory block metadata.
unsigned int(* memtrack_addblock)(const void *p_Ptr, const size_t p_Size, const char *p_File, const int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function)
Functor to register an allocated memory block metadata.