memory.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  $RCSfile$
00003  -------------------
00004  cvs         : $Id: memory.h 1393 2007-11-22 18:26:05Z martin $
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   int GWEN_Memory_ModuleInit();
00063 
00064   GWENHYWFAR_API 
00065   int GWEN_Memory_ModuleFini();
00066 
00067 
00068   GWENHYWFAR_API
00069   void *GWEN_Memory_malloc(size_t dsize);
00070   GWENHYWFAR_API
00071   void GWEN_Memory_dealloc(void *p);
00072 
00073   GWENHYWFAR_API
00074   void *GWEN_Memory_realloc(void *oldp, size_t nsize);
00075 
00076   GWENHYWFAR_API 
00077   char *GWEN_Memory_strdup(const char *s);
00078 
00079   GWENHYWFAR_API 
00080   void GWEN_Memory_Collect();
00081 
00082   GWENHYWFAR_API 
00083   void GWEN_Memory_Dump();
00084 
00085 
00086 #define GWEN_MEM_NEW(typ, memptr) \
00087   memptr=(typ*)GWEN_Memory_malloc(sizeof(typ));
00088 
00089 #define GWEN_MEM_FREE(varname) \
00090   GWEN_Memory_dealloc((void*)varname);
00091 
00092 
00093 #define GWEN_NEW_OBJECT(typ, varname)\
00094   {\
00095     varname=(typ*)GWEN_Memory_malloc(sizeof(typ)); \
00096     memset(varname, 0, sizeof(typ));\
00097   }
00098 
00099 #define GWEN_FREE_OBJECT(varname) \
00100   GWEN_Memory_dealloc((void*)varname);
00101 
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 
00108 #endif /* GWENHYWFAR_MEMORY_H */
00109 

Generated on Fri Apr 11 01:53:47 2008 for gwenhywfar by  doxygen 1.5.5