src/mem.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. vf_free

   1 /*
   2  * mem.c  --- memory manager
   3  *
   4  */
   5 /*
   6  * Copyright (C) 2001  Hirotsugu Kakugawa. 
   7  * All rights reserved.
   8  *
   9  * This file is part of the VFlib Library.  This library is free
  10  * software; you can redistribute it and/or modify it under the terms of
  11  * the GNU Library General Public License as published by the Free
  12  * Software Foundation; either version 2 of the License, or (at your
  13  * option) any later version.  This library is distributed in the hope
  14  * that it will be useful, but WITHOUT ANY WARRANTY; without even the
  15  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  16  * PURPOSE.  See the GNU Library General Public License for more details.
  17  * You should have received a copy of the GNU Library General Public
  18  * License along with this library; if not, write to the Free Software
  19  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20  */
  21 
  22 #include "config.h"
  23 #include <stdio.h>
  24 #include <stdlib.h>
  25 #include <ctype.h>
  26 #ifdef HAVE_UNISTD_H
  27 #  include <unistd.h>
  28 #endif
  29 #if HAVE_STRING_H
  30 # include <string.h>
  31 #endif
  32 #if HAVE_STRINGS_H
  33 # include <strings.h>
  34 #endif
  35 #include <sys/types.h>
  36 #include <sys/param.h>
  37 
  38 #include "VFlib-3_6.h"
  39 #include "VFsys.h"
  40 
  41 
  42 
  43 Glocal void
  44 vf_free(void *p) 
     /* [<][>][^][v][top][bottom][index][help] */
  45 {
  46   static  int  init = 0;
  47   static  void *xaddr = NULL;
  48 
  49   if (init == 0){
  50     init = 1;
  51     if (getenv("VFLIB_DEBUG_FREE") != NULL){
  52       sscanf(getenv("VFLIB_DEBUG_FREE"), "%p", &xaddr);
  53     }
  54   }
  55 
  56   if (p == NULL)
  57     return;
  58 
  59   if ((xaddr != NULL) && (p == xaddr)){
  60     fprintf(stderr, "VFlib error in free\n");
  61     abort();
  62   }
  63 
  64   free(p);
  65 }
  66 
  67 
  68 /*EOF*/

/* [<][>][^][v][top][bottom][index][help] */