|
| iMatix home page | << | < | > | >> |
SFLVersion 2.10 |
#include "sflmem.h"
void
mem_assert_ (
const char *filename, /* Name of source file making call */
size_t lineno /* Line number in calling source */
)
Checks that all allocated memory was freed. Use the mem_assert macro to call this function! If any memory is still left allocated, displays the memory list on stderr and aborts. Generally we use this function at the end of a program, after deallocating all memory. If any memory has not been allocated, we get a nice list and an abort. Our principle is that any memory allocation must be matched by a free somewhere in the code.
{
FILE
*trace_file;
if (mem_total != 0
|| !list_empty (&tr_list))
{
fflush (stdout);
fprintf (stderr, "Clean-memory assertion failed - %s (%d)\n",
filename? filename: "<Unknown>", lineno);
fprintf (stderr, "Details are in memtrace.lst\n");
trace_file = fopen ("memtrace.lst", "w");
mem display (trace_file);
fclose (trace_file);
abort ();
}
}
| | << | < | > | >> |
|