PoolAllocationBase.h

Go to the documentation of this file.
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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00056 
00057 namespace OpenDDS {
00058 namespace DCPS {
00059 
00060 class PoolAllocationBase
00061 {
00062 public:
00063   OPENDDS_POOL_ALLOCATION_HOOKS
00064 };
00065 
00066 }
00067 }
00068 
00069 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00070 
00071 #endif /* dds_DCPS_PoolAllocationBase_h */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1