NAME

watch_for_free - (Debugging) Watches for free of a pointer

SYNOPSIS

#include "l/l_sys_mal.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


void watch_for_free(void *ptr);

DESCRIPTION

In development code, this routine checks for an inadvertant free of the pointer argument. The watch is terminated by using a NULL argument. If the pointer is freed before that time, then you are prompted for an abort. To state the obvious, the watch should be terminated before a non-inadvertant free is called. The typical use is : | allocation of "ptr"
     watch_for_free(ptr);
     code which is suspected of freeing ptr when it should not
     watch_for_free(NULL);
     free of "ptr"
In production code, watch_for_free() is defined as a NULL macro, so it disapears. However, normally watch_for_free() is simply inserted for a run, and then removed. Unfortunately, only one pointer can be watched at present.

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

memory_used , kjb_malloc , kjb_calloc , kjb_realloc , check_initialization , optimize_free , optimize_free_2 , kjb_free