00001 #ifndef dds_DCPS_PoolAllocationBase_h
00002 #define dds_DCPS_PoolAllocationBase_h
00003
00004 #include <new>
00005 #include "SafetyProfilePool.h"
00006
00007 #define OPENDDS_POOL_ALLOCATION_HOOKS \
00008 void* operator new(size_t size) \
00009 { \
00010 void* const ptr = ACE_Allocator::instance()->malloc(size); \
00011 if (ptr == 0) { \
00012 throw std::bad_alloc(); \
00013 } \
00014 return ptr; \
00015 } \
00016 \
00017 void operator delete(void* ptr) \
00018 { ACE_Allocator::instance()->free(ptr); } \
00019 \
00020 void* operator new(size_t size, const std::nothrow_t&) throw() \
00021 { return ACE_Allocator::instance()->malloc(size); } \
00022 \
00023 void operator delete(void* ptr, const std::nothrow_t&) \
00024 { ACE_Allocator::instance()->free(ptr); } \
00025 \
00026 void* operator new(size_t, void* ptr) { return ptr; } \
00027 \
00028 void operator delete(void*, void*) {} \
00029 \
00030 void* operator new[](size_t size) \
00031 { \
00032 void* const ptr = ACE_Allocator::instance()->malloc(size); \
00033 if (ptr == 0) { \
00034 throw std::bad_alloc(); \
00035 } \
00036 return ptr; \
00037 } \
00038 \
00039 void operator delete[](void* ptr) \
00040 { ACE_Allocator::instance()->free(ptr); } \
00041 \
00042 void* operator new[](size_t size, const std::nothrow_t&) throw() \
00043 { return ACE_Allocator::instance()->malloc(size); } \
00044 \
00045 void operator delete[](void* ptr, const std::nothrow_t&) \
00046 { ACE_Allocator::instance()->free(ptr); } \
00047
00048
00049 #define OPENDDS_POOL_ALLOCATION_FWD \
00050 using PoolAllocationBase::operator new; \
00051 using PoolAllocationBase::operator new[]; \
00052 using PoolAllocationBase::operator delete; \
00053 using PoolAllocationBase::operator delete[]; \
00054
00055
00056 namespace OpenDDS {
00057 namespace DCPS {
00058
00059 class PoolAllocationBase
00060 {
00061 public:
00062 OPENDDS_POOL_ALLOCATION_HOOKS
00063 };
00064
00065 }
00066 }
00067
00068 #endif