X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2FUtil%2Fnewalloc.h;h=9e583c9d591e1980f09257ae8e6c082b9f46015c;hb=5df1b9a579235d42fcec8a8884808334ed99a246;hp=e0fb3309b6dac6bf3a9ca8f7ba7b29c13038bace;hpb=11e3839c21831fa11d5508b05a57320e02f12330;p=fw%2Fsdcc diff --git a/support/Util/newalloc.h b/support/Util/newalloc.h index e0fb3309..9e583c9d 100644 --- a/support/Util/newalloc.h +++ b/support/Util/newalloc.h @@ -33,6 +33,13 @@ functions. #include +typedef struct _allocTrace +{ + int num; + int max; + void **palloced; +} allocTrace; + /* ------------------------------------------------------------------------------- Clear_realloc - Reallocate a memory block and clear any memory added with @@ -72,4 +79,25 @@ and checking for out or memory errors. void *Safe_malloc(size_t Size) ; +/** Replacement for Safe_malloc that also zeros memory. To make it interchangable. + */ +void *Safe_alloc(size_t Size) ; + +/** Function to make the replacements complete. + */ +void Safe_free(void *p); + +/** Creates a copy of a string in a safe way. + */ +char *Safe_strdup(const char *sz); + +/** Logs the allocated memory 'p' in the given trace for batch freeing + later using freeTrace. +*/ +void *traceAlloc(allocTrace *ptrace, void *p); + +/** Frees all the memory logged in the trace and resets the trace. + */ +void freeTrace(allocTrace *ptrace); + #endif