23 #ifndef __ODAALLOCOP_H__
24 #define __ODAALLOCOP_H__
31 #if !defined(_WIN32_WCE)
34 #pragma warning(disable: 4290)
37 #if (defined(__GNUC__) && __GNUC__ >= 5) || (defined(_MSC_VER) && _MSC_VER >= 1800)
38 #define ODRX_SIZED_DEALLOC_OPERATORS() \
39 void operator delete(void* p, std::size_t) \
44 void operator delete[](void* p, std::size_t) \
49 void operator delete(void* ptr, std::size_t s, const std::nothrow_t&) \
51 operator delete(ptr, s); \
53 void operator delete[](void* ptr, std::size_t s, const std::nothrow_t&) \
55 operator delete[](ptr, s); \
59 #define ODRX_SIZED_DEALLOC_OPERATORS()
62 #define ODRX_NOTHROW_ALLOC_OPERATORS() \
63 void *operator new (size_t size, const std::nothrow_t&) throw() { return operator new(size); } \
64 void * operator new[] (::size_t count, const std::nothrow_t&) throw() { return operator new[](count); }\
65 void operator delete[](void *ptr, const std::nothrow_t&) throw() { operator delete[](ptr); } \
66 void operator delete (void *ptr, const std::nothrow_t&) throw() { operator delete(ptr); } \
69 #define ODRX_ALLOC_OPERATORS() \
70 void* operator new (size_t size) throw(std::bad_alloc) \
72 void* p = ::odrxAlloc(size); \
75 void operator delete (void *p) throw() \
80 void* operator new[](size_t size) throw(std::bad_alloc) \
82 void* p = ::odrxAlloc(size); \
85 void operator delete[](void *p) throw() \
90 ODRX_NOTHROW_ALLOC_OPERATORS() \
91 ODRX_SIZED_DEALLOC_OPERATORS() \
94 #define ODRX_ALLOC_OPERATORS() \
95 void* operator new (size_t size) throw(std::bad_alloc) \
97 void* p = ::odrxAlloc(size); \
99 if (!p && size) throw std::bad_alloc(); \
102 void operator delete (void *p) throw() \
107 void* operator new[](size_t size) throw(std::bad_alloc) \
109 void* p = ::odrxAlloc(size); \
110 if (!p && size) throw std::bad_alloc(); \
113 void operator delete[](void *p) throw() \
118 ODRX_NOTHROW_ALLOC_OPERATORS() \
119 ODRX_SIZED_DEALLOC_OPERATORS() \
124 #define ODRX_ALLOC_OPERATORS()
125 #define ODRX_CRTDBG_MAP_ALLOC_OPERATORS()
131 #if (_MSC_VER >= 1200) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
133 #define ODRX_CRTDBG_MAP_ALLOC_OPERATORS() \
134 extern "C" { extern _CRTIMP void * __cdecl _malloc_dbg(size_t, int, const char *, int); } \
135 void* __cdecl operator new(size_t size, int type, const char* fname, int line) { return _malloc_dbg(size, type, fname, line); } \
136 void* __cdecl operator new[](size_t size, int type, const char* fname, int line) { return operator new(size, type, fname, line); } \
141 #define TD_CDECL __cdecl
146 #if !defined(_WIN32_WCE)
147 #define ODRX_CRTDBG_MAP_ALLOC_OPERATORS() \
148 void* TD_CDECL operator new(size_t size, int, const char*,int) { return ::operator new(size); } \
149 void* TD_CDECL operator new[](size_t size, int, const char*, int) { return ::operator new[](size); }