gwenhywfar 4.0.3
|
00001 /*************************************************************************** 00002 $RCSfile$ 00003 ------------------- 00004 cvs : $Id$ 00005 begin : Sat Jun 28 2003 00006 copyright : (C) 2003 by Martin Preuss 00007 email : martin@libchipcard.de 00008 00009 *************************************************************************** 00010 * * 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU Lesser General Public * 00013 * License as published by the Free Software Foundation; either * 00014 * version 2.1 of the License, or (at your option) any later version. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00019 * Lesser General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU Lesser General Public * 00022 * License along with this library; if not, write to the Free Software * 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00024 * MA 02111-1307 USA * 00025 * * 00026 ***************************************************************************/ 00027 00028 00029 #ifndef GWENHYWFAR_MEMORY_H 00030 #define GWENHYWFAR_MEMORY_H 00031 00032 #include <gwenhywfar/gwenhywfarapi.h> 00033 #include <gwenhywfar/types.h> 00034 #include <gwenhywfar/error.h> 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 #include <string.h> 00038 #include <assert.h> 00039 00040 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 00047 /* this is taken from the system header file assert.h and 00048 * and modified by me (Martin Preuss). 00049 */ 00050 # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4) 00051 # define GWEN_LOCATION_FUNCTION __PRETTY_FUNCTION__ 00052 # else 00053 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 00054 # define GWEN_LOCATION_FUNCTION __func__ 00055 # else 00056 # define GWEN_LOCATION_FUNCTION ((__const char *) "unknown function") 00057 # endif 00058 # endif 00059 00060 00061 GWENHYWFAR_API 00062 void *GWEN_Memory_malloc(size_t dsize); 00063 GWENHYWFAR_API 00064 void GWEN_Memory_dealloc(void *p); 00065 00066 GWENHYWFAR_API 00067 void *GWEN_Memory_realloc(void *oldp, size_t nsize); 00068 00069 GWENHYWFAR_API 00070 char *GWEN_Memory_strdup(const char *s); 00071 00072 GWENHYWFAR_API 00073 void GWEN_Memory_Collect(); 00074 00075 GWENHYWFAR_API 00076 void GWEN_Memory_Dump(); 00077 00078 00079 #define GWEN_MEM_NEW(typ, memptr) \ 00080 memptr=(typ*)GWEN_Memory_malloc(sizeof(typ)); 00081 00082 #define GWEN_MEM_FREE(varname) \ 00083 GWEN_Memory_dealloc((void*)varname); 00084 00085 00086 #define GWEN_NEW_OBJECT(typ, varname)\ 00087 {\ 00088 varname=(typ*)GWEN_Memory_malloc(sizeof(typ)); \ 00089 memset(varname, 0, sizeof(typ));\ 00090 } 00091 00092 #define GWEN_FREE_OBJECT(varname) \ 00093 GWEN_Memory_dealloc((void*)varname); 00094 00095 00096 #ifdef __cplusplus 00097 } 00098 #endif 00099 00100 00101 #endif /* GWENHYWFAR_MEMORY_H */ 00102