/[escript]/branches/windows_from_1456_trunk_1580_merged_in/esysUtils/src/esys_malloc.h
ViewVC logotype

Contents of /branches/windows_from_1456_trunk_1580_merged_in/esysUtils/src/esys_malloc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1587 - (show annotations)
Thu Jun 5 05:50:20 2008 UTC (12 years, 2 months ago) by phornby
File MIME type: text/plain
File size: 1326 byte(s)
define esysUtils::malloc() and friends to dress naked mallocs in C++ code.

Remove unneedded PyObject_NEW macros from Common.h.

Add needed system include files to blocktimer.c

Dress the naked mallocs in DataFactory and DataTagged.


1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 /**
17 \file esys_malloc.h
18 \ingroup Other
19 */
20 //
21 // @(#) esys_malloc.h
22 //
23
24 #ifndef esys_malloc_h
25 #define esys_malloc_h
26
27 #ifdef _WIN32
28
29 # ifdef _DEBUG
30 # define TMP_DEF_FLAG
31 # undef _DEBUG
32 # endif
33 # include <python.h>
34 # ifdef TMP_DEF_FLAG
35 # undef TMP_DEF_FLAG
36 # define _DEBUG
37 # endif
38 # define ESYS_MALLOC PyMem_Malloc
39 # define ESYS_FREE PyMem_Free
40 # define ESYS_REALLOC PyMem_Realloc
41
42 #else
43 # include <malloc.h>
44 # define ESYS_MALLOC malloc
45 # define ESYS_FREE free
46 # define ESYS_REALLOC realloc
47
48 #endif
49
50 namespace esysUtils
51 {
52
53 inline
54 void *malloc(size_t len)
55 {
56 return ESYS_MALLOC(len);
57 }
58
59 inline
60 void free(void *ptr)
61 {
62 ESYS_FREE(ptr);
63 return;
64 }
65
66 inline
67 void *realloc(void *ptr, size_t len)
68 {
69 return ESYS_REALLOC(ptr,len);
70 }
71 }
72
73 #undef ESYS_MALLOC
74 #undef ESYS_FREE
75 #undef ESYS_REALLOC
76
77 #endif

  ViewVC Help
Powered by ViewVC 1.1.26