00001 /* 00002 * $Id: memory.h,v 1.15 2003/10/16 18:50:54 jasta Exp $ 00003 * 00004 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __MEMORY_H 00018 #define __MEMORY_H 00019 00020 /*****************************************************************************/ 00021 00028 /*****************************************************************************/ 00029 00030 #undef CALLOC 00031 #undef MALLOC 00032 #undef FREE 00033 #undef REALLOC 00034 00035 /* 00036 * TCGProf is a simple memory profiling tool designed to debug only 00037 * allocations localized to the users defined space, so anything beyond 00038 * memory.h will use it. 00039 * 00040 * Please note that in order to use tcgprof you must disable libltdl support. 00041 * Don't ask me why, I just know that tcg_dump_mem() segfaults after a call 00042 * to ltdl_exit() or ltdl_close(). I would assume this is because any 00043 * allocations made in the plugins space are cleaned up and thus the 00044 * references that remain in the tcgprof table are invalid. That's all I can 00045 * come up with, anyway... 00046 */ 00047 #ifdef USE_TCGPROF 00048 # include <tcgprof.h> 00049 #endif /* USE_TCGPROF */ 00050 00051 #ifndef USE_TCGPROF 00052 # define CALLOC(nmemb,size) gift_calloc(nmemb,size) 00053 # define MALLOC(size) CALLOC(1,size) 00054 # define NEW(type) MALLOC(sizeof(type)) 00055 # define FREE(ptr) gift_free(ptr) 00056 # define REALLOC(ptr,size) gift_realloc(ptr,size) 00057 #else /* USE_TCGPROF */ 00058 # define CALLOC(nmemb,size) calloc(nmemb,size) 00059 # define MALLOC(size) CALLOC(1,size) 00060 # define NEW(type) MALLOC(sizeof(type)) 00061 # define FREE(ptr) free(ptr) 00062 # define REALLOC(ptr,size) realloc(ptr,size) 00063 #endif /* !USE_TCGPROF */ 00064 00065 /*****************************************************************************/ 00066 00067 EXTERN_C_BEGIN 00068 00069 /*****************************************************************************/ 00070 00074 LIBGIFT_EXPORT 00075 void *gift_malloc (size_t size); 00076 00080 LIBGIFT_EXPORT 00081 void *gift_calloc (size_t nmemb, size_t size); 00082 00086 LIBGIFT_EXPORT 00087 void gift_free (void *ptr); 00088 00093 LIBGIFT_EXPORT 00094 void *gift_realloc (void *ptr, size_t size); 00095 00096 /*****************************************************************************/ 00097 00102 LIBGIFT_EXPORT 00103 void *gift_memdup (const void *ptr, size_t size); 00104 00105 /*****************************************************************************/ 00106 00107 EXTERN_C_END 00108 00109 /*****************************************************************************/ 00110 00111 #endif /* __MEMORY_H */
1.3.7