APEMoST

src/memory.h

Go to the documentation of this file.
00001 /*
00002     APEMoST - Automated Parameter Estimation and Model Selection Toolkit
00003     Copyright (C) 2009  Johannes Buchner
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, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00023 #ifndef MEMORY_H_
00024 #define MEMORY_H_
00025 
00026 #include "debug.h"
00027 
00028 #define FREEMSG(x) IFSEGV dump_p("about to free", (void*)x);
00029 
00030 #ifdef __NEVER_SET_FOR_DOCUMENTATION_ONLY
00031 
00037 #define WITHOUT_GARBAGE_COLLECTOR
00038 #endif
00039 
00040 #ifdef WITHOUT_GARBAGE_COLLECTOR
00041 
00042 #define mem_malloc(x) malloc(x)
00043 #define mem_calloc(n,x) calloc(n, x)
00044 #define mem_realloc(p,x) realloc(p,x)
00045 #define mem_free(x) { FREEMSG(x); free((void*)x); }
00046 
00047 #else
00048 
00049 #include <gc/gc.h>
00050 
00051 #define mem_malloc(x) GC_malloc(x)
00052 #define mem_calloc(n,x) GC_malloc((n)*(x))
00053 #define mem_realloc(p,x) GC_realloc((p),(x))
00054 #define mem_free(x) { FREEMSG(x); (x) = NULL; }
00055 
00056 #endif
00057 
00058 #ifdef NOFREE
00059 #define gsl_vector_free(v)
00060 #endif
00061 
00062 #endif /* MEMORY_H_ */