1 /***************************************************************************
2  begin       : Sat Jun 28 2003
3  copyright   : (C) 2019 by Martin Preuss
4  email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  *                                                                         *
8  *   This library is free software; you can redistribute it and/or         *
9  *   modify it under the terms of the GNU Lesser General Public            *
10  *   License as published by the Free Software Foundation; either          *
11  *   version 2.1 of the License, or (at your option) any later version.    *
12  *                                                                         *
13  *   This library is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
16  *   Lesser General Public License for more details.                       *
17  *                                                                         *
18  *   You should have received a copy of the GNU Lesser General Public      *
19  *   License along with this library; if not, write to the Free Software   *
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
21  *   MA  02111-1307  USA                                                   *
22  *                                                                         *
23  ***************************************************************************/
24 
25 
26 #ifndef GWENHYWFAR_MEMORY_H
27 #define GWENHYWFAR_MEMORY_H
28 
29 #include <gwenhywfar/gwenhywfarapi.h>
30 
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 
38 
39 GWENHYWFAR_API void *GWEN_Memory_malloc(size_t dsize);
40 GWENHYWFAR_API void GWEN_Memory_dealloc(void *p);
41 
42 GWENHYWFAR_API void *GWEN_Memory_realloc(void *oldp, size_t nsize);
43 
44 GWENHYWFAR_API char *GWEN_Memory_strdup(const char *s);
45 
46 
47 
48 #define GWEN_MEM_NEW(typ, memptr) \
49   memptr=(typ*)GWEN_Memory_malloc(sizeof(typ));
50 
51 #define GWEN_MEM_FREE(varname) \
52   GWEN_Memory_dealloc((void*)varname);
53 
54 
55 #define GWEN_NEW_OBJECT(typ, varname)\
56   {\
57     varname=(typ*)GWEN_Memory_malloc(sizeof(typ)); \
58     memset(varname, 0, sizeof(typ));\
59   }
60 
61 #define GWEN_FREE_OBJECT(varname) \
62   GWEN_Memory_dealloc((void*)varname);
63 
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 
70 #endif /* GWENHYWFAR_MEMORY_H */
71 
72