void lib_FreeMem(void *ptr, unsigned long size) { #ifdef LIB_DEBUG lib_debug_free(ptr, 1, 1); lib_debug_libc_free(ptr); #else FreeMem(ptr, size); #endif }
void lib_FreeVec(void *ptr) { #ifdef LIB_DEBUG lib_debug_free(ptr, 1, 1); lib_debug_libc_free(ptr); #else FreeVec(ptr); #endif }
void lib_free(const void *constptr) { void * ptr = (void*) constptr; #ifdef LIB_DEBUG lib_debug_free(ptr, 1, 1); #endif #ifdef LIB_DEBUG lib_debug_libc_free(ptr); #else free(ptr); #endif }
/* Like realloc, but abort if not enough memory is available. */ void *lib_realloc(void *ptr, size_t size) { #ifdef LIB_DEBUG void *new_ptr = lib_debug_libc_realloc(ptr, size); #else void *new_ptr = realloc(ptr, size); #endif #ifndef __OS2__ if (new_ptr == NULL) exit(-1); #endif #ifdef LIB_DEBUG lib_debug_free(ptr, 1, 0); lib_debug_alloc(new_ptr, size, 1); #endif return new_ptr; }
/* Like realloc, but abort if not enough memory is available. */ void *lib_realloc(void *ptr, size_t size) { #ifdef LIB_DEBUG void *new_ptr = lib_debug_libc_realloc(ptr, size); #else void *new_ptr = realloc(ptr, size); #endif #ifndef __OS2__ if (new_ptr == NULL) { fprintf(stderr, "error: lib_realloc failed\n"); exit(-1); } #endif #ifdef LIB_DEBUG lib_debug_free(ptr, 1, 0); lib_debug_alloc(new_ptr, size, 1); #endif return new_ptr; }