Debugging
If F_MEMORY_DEBUG is enabled, the memory debugging system will create macros that replace malloc, free and realloc and allows the system to keppt track of and report where memory is beeing allocated, how much and if the memory is beeing freed. This is very useful for finding memory leaks in large applications. The system can also over allocate memory and fill it with a magic number and can therfor detect if the application writes outside of the allocated memory. if F_EXIT_CRASH is defined, then exit(); will be replaced with a funtion that writes to NULL. This will make it trivial ti find out where an application exits using any debugger.,
f_debug_memory_init
void f_debug_memory_init(void (*lock)(void *mutex), void (*unlock)(void *mutex), void *mutex);
Description: Required for memory debugger to be thread safef_debug_mem_malloc
void *f_debug_mem_malloc(uint size, char *file, uint line);
Description: Replaces malloc and records the c file and line where it was calledf_debug_mem_realloc
void *f_debug_mem_realloc(void *pointer, uint size, char *file, uint line);
Description: Replaces realloc and records the c file and line where it was calledf_debug_mem_free
void f_debug_mem_free(void *buf);
Description: Replaces free and records the c file and line where it was calledf_debug_mem_print
void f_debug_mem_print(uint min_allocs);
Description: Prints out a list of all allocations made, their location, how much memorey each has allocated, freed, and how many allocations have been made. The min_allocs parameter can be set to avoid printing any allocations that have been made fewer times then min_allocsf_debug_mem_reset
void f_debug_mem_reset();
Description: f_debug_mem_reset allows you to clear all memory stored in the debugging system if you only want to record allocations after a specific point in your codef_debug_memory
boolean f_debug_memory();
Description: f_debug_memory checks if any of the bounds of any allocation has been over written and reports where to standard out. The function returns TRUE if any error was foundexit_crash
void exit_crash(uint i);
Description: finction guaranteed to crash (Writes to NULL).