Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

Memory.h

Go to the documentation of this file.
00001 /*
00002  *    gui - [gega user interface] the flexible solution for user interface problems
00003  *    Copyright (C) 2002  Gergely Gati
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; version 2 of the License.
00008  *
00009  *    This program is distributed in the hope that it will be useful,
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *    GNU General Public License for more details.
00013  *
00014  *    You should have received a copy of the GNU General Public License
00015  *    along with this program; if not, write to the Free Software
00016  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  *    Gergely Gati
00019  *      email:           g.gati@freemail.hu
00020  *      AIM screenname:  GatiGergely
00021  *      ICQ number:      93131690
00022  *
00023  */
00024 #ifndef __MEMORY_H
00025 #define __MEMORY_H
00026 
00027 /* IN debug.h :
00028 //#define MEM_MACRO
00029 //#define MEM_OVER
00030 //#define MEM_VERBOSE
00031 */
00032 
00033 #include "debug.h"
00034 
00035 
00036 
00037 #ifdef MEM_OVER
00038   #ifdef MEM_MACRO
00039     #error "Cannot use macro and over mode at the same time"
00040   #endif
00041 #endif
00042 
00043 
00044 #ifdef MEM_VERBOSE
00045 #if !defined (MEM_OVER)
00046 #error "Cannot use verbose mode without over mode"
00047 #endif
00048 #endif
00049 
00050 #ifdef MEM_MACRO
00051 
00052   #include <stdio.h>
00053   #include <stdlib.h>
00054 
00055   #define mem_malloc(s)     malloc((size_t)s)
00056   #define mem_calloc(n,s)   calloc(n,(size_t)s)
00057   #define mem_free(p)       free(p)
00058   #define mem_trace_checkpoint()
00059   #define mem_trace_report()
00060 
00061 #else /* MEM_MACRO */
00062 
00063   #ifdef MEM_OVER
00064     #ifndef INMEM
00065       #define mem_malloc(s)   mem_malloc_over(s,__FILE__,__FUNCTION__,__LINE__)
00066       #define mem_calloc(n,s) mem_calloc_over(n,s,__FILE__,__FUNCTION__,__LINE__)
00067       #define mem_free(p)     mem_free_over(p,__FILE__,__FUNCTION__,__LINE__)
00068     #endif /* INMEM */
00069     void *mem_malloc_over(size_t size, char *file, char *func, int line);
00070     void *mem_calloc_over(size_t nmemb, size_t size, char *file, char *func, int line);
00071     void mem_free_over(void *ptr, char *file, char *func, int line);
00072   #else
00073     void *mem_malloc(size_t size);
00074     void *mem_calloc(size_t nmemb, size_t size);
00075     void *mem_realloc(void *ptr, size_t size);
00076     void mem_free(void *ptr);
00077   #endif /* MEM_OVER */
00078 
00079   #define mem_trace_checkpoint()
00080   void mem_trace_report(void);
00081 
00082 #endif /* MEM_MACRO */
00083 
00084 #endif

Generated on Tue Jan 7 12:11:23 2003 for THEGUI by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002