| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflmem.h" void mem_free_ ( void *client_ptr, /* Block of memory to free */ const char *filename, /* Name of source file making call */ size_t lineno /* Line number in calling source */ )
Releases memory previously allocated by mem alloc (), mem realloc (), or mem strdup (). Use the mem_free() macro to call this function! If the specified block was not correctly allocated, dumps the memory allocation list and exits. If you specify a null address, does nothing.
{ MEMHDR *ptr; if (client_ptr == NULL) /* Do nothing if address is null */ return; /* Check for valid block */ ptr = CLIENT_2_HDR (client_ptr); if (ptr-> tag != MEMTAG) mem_tag_err (ptr, filename, lineno); # if (defined (MEM_TRACE)) trace ("%s (%ld): free=%p", filename? filename: "-", (long) lineno, ptr); # endif # if (defined (DEBUG)) memset (client_ptr, 0, ptr-> size); # endif /* Invalidate header */ ptr-> tag = MEMUNTAG; mem_total -= ptr-> size; mem_free_count += 1; /* Remove block from list, inlining code from list unlink() */ ((LIST *) ((LIST *) ptr)-> prev)-> next = ((LIST *) ptr)-> next; ((LIST *) ((LIST *) ptr)-> next)-> prev = ((LIST *) ptr)-> prev; free (ptr); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |