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