| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 1.91

 

mem_free_

#include "sflmem.h"
void
mem_free_ (
    void *client_ptr,                   /*  Block of memory to free          */
    const char *filename,               /*  Name of source file making call  */
    word lineno                         /*  Line number in calling source    */
)

Synopsis

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.

Source Code - (sflmem.c)

{
    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))
    if (filename)
        trace ("%s (%d): free=%p", filename, lineno, ptr);
#   endif

    /*  Invalidate header                                                    */
    ptr-> tag = (word) ~MEMTAG;
    mem_size -= ptr-> size;
    mem_free_count += 1;
    list unlink (ptr);                  /*  Remove block from list           */

    free (ptr);
}

| << | < | > | >> iMatix Copyright © 1996-98 iMatix