Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef INC_ESYS_MEM
00016 #define INC_ESYS_MEM
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdlib.h>
00042
00043 #define PASO_MALLOC malloc
00044 #define PASO_FREE free
00045 #define PASO_REALLOC realloc
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #if defined(__ECC) && defined(_OPENMP)
00057 #include <omp.h>
00058 #define PASO_THREAD_MALLOC kmp_malloc
00059 #define PASO_THREAD_FREE kmp_free
00060 #else
00061 #define PASO_THREAD_MALLOC PASO_MALLOC
00062 #define PASO_THREAD_FREE PASO_FREE
00063 #endif
00064
00065
00066
00067
00068
00069 #define PASO_DLL_API
00070
00071 #ifdef _WIN32
00072 # ifndef PASO_STATIC_LIB
00073 # undef PASO_DLL_API
00074 # ifdef PASO_EXPORTS
00075 # define PASO_DLL_API __declspec(dllexport)
00076 # else
00077 # define PASO_DLL_API __declspec(dllimport)
00078 # endif
00079 # endif
00080 #endif
00081
00082
00083
00084
00085 #define MEMALLOC(_LENGTH_,_TYPE_) \
00086 (_TYPE_*) PASO_MALLOC(((size_t)(_LENGTH_))*sizeof(_TYPE_))
00087
00088
00089
00090
00091 #define MEMFREE(_PTR_) \
00092 do \
00093 { \
00094 if ((void *)(_PTR_) != NULL ) { PASO_FREE(_PTR_); (_PTR_) = NULL; } \
00095 } while(0)
00096
00097 #define MEMREALLOC(_RETP_,_POINTER_,_LENGTH_,_TYPE_) \
00098 do \
00099 { \
00100 if( (_POINTER_)!=NULL ) \
00101 { \
00102 _RETP_ = (_TYPE_*)PASO_REALLOC((void*)(_POINTER_), \
00103 ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); \
00104 } \
00105 else \
00106 { \
00107 _RETP_ = (_TYPE_*)PASO_MALLOC( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); \
00108 } \
00109 } while(0)
00110
00111 #define TMPMEMALLOC MEMALLOC
00112 #define TMPMEMFREE MEMFREE
00113 #define TMPMEMREALLOC MEMREALLOC
00114
00115 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) \
00116 (_TYPE_*) PASO_THREAD_MALLOC(((size_t)(_LENGTH_))*sizeof(_TYPE_))
00117
00118 #define THREAD_MEMFREE(_PTR_) \
00119 do \
00120 { \
00121 if ((void *)(_PTR_) != NULL ) { PASO_THREAD_FREE(_PTR_); (_PTR_) = NULL; } \
00122 } while(0)
00123
00124
00125 #endif