/** * Frees a block of memory. A direct replacement for free, but checks that a item is in * the allocates list first. * @param file use the __FILE__ macro to indicate which file this item was allocated in * @param line use the __LINE__ macro to indicate which line this item was allocated at * @param p pointer to the item to be freed */ void myfree(char* file, int line, void* p) { Thread_lock_mutex(heap_mutex); if (Internal_heap_unlink(file, line, p)) deallocate(((int*)p)-1); Thread_unlock_mutex(heap_mutex); }
/** * Frees a block of memory. A direct replacement for free, but checks that a item is in * the allocates list first. * @param file use the __FILE__ macro to indicate which file this item was allocated in * @param line use the __LINE__ macro to indicate which line this item was allocated at * @param p pointer to the item to be freed */ void myfree(char* file, int line, void* p) { if (p) /* it is legal und usual to call free(NULL) */ { Thread_lock_mutex(heap_mutex); if (Internal_heap_unlink(file, line, p)) free(((int*)p)-1); Thread_unlock_mutex(heap_mutex); } else { Log(LOG_ERROR, -1, "Call of free(NULL) in %s,%d",file,line); } }
/** * Remove an item from the recorded heap without actually freeing it. * Use sparingly! * @param file use the __FILE__ macro to indicate which file this item was allocated in * @param line use the __LINE__ macro to indicate which line this item was allocated at * @param p pointer to the item to be removed */ void Heap_unlink(char* file, int line, void* p) { Thread_lock_mutex(heap_mutex); Internal_heap_unlink(file, line, p); Thread_unlock_mutex(heap_mutex); }
/** * Frees a block of memory. A direct replacement for free, but checks that a item is in * the allocates list first. * @param file use the __FILE__ macro to indicate which file this item was allocated in * @param line use the __LINE__ macro to indicate which line this item was allocated at * @param p pointer to the item to be freed */ void myfree(char* file, int line, void* p) { Internal_heap_unlink(file, line, p); free(p); }
/** * Remove an item from the recorded heap without actually freeing it. * Use sparingly! * @param file use the __FILE__ macro to indicate which file this item was allocated in * @param line use the __LINE__ macro to indicate which line this item was allocated at * @param p pointer to the item to be removed */ void Heap_unlink(char* file, int line, void* p) { Internal_heap_unlink(file, line, p); }