OpenDDS  Snapshot(2023/04/28-20:55)
PoolAllocationBase.h
Go to the documentation of this file.
1 #ifndef OPENDDS_DCPS_POOLALLOCATIONBASE_H
2 #define OPENDDS_DCPS_POOLALLOCATIONBASE_H
3 
4 #include <new>
5 #include "SafetyProfilePool.h"
6 
7 #define OPENDDS_POOL_ALLOCATION_HOOKS \
8  void* operator new(size_t size) \
9  { \
10  void* const ptr = ACE_Allocator::instance()->malloc(size); \
11  if (ptr == 0) { \
12  throw std::bad_alloc(); \
13  } \
14  return ptr; \
15  } \
16  \
17  void operator delete(void* ptr) \
18  { ACE_Allocator::instance()->free(ptr); } \
19  \
20  void* operator new(size_t size, const std::nothrow_t&) throw() \
21  { return ACE_Allocator::instance()->malloc(size); } \
22  \
23  void operator delete(void* ptr, const std::nothrow_t&) \
24  { ACE_Allocator::instance()->free(ptr); } \
25  \
26  void* operator new(size_t, void* ptr) { return ptr; } \
27  \
28  void operator delete(void*, void*) {} \
29  \
30  void* operator new[](size_t size) \
31  { \
32  void* const ptr = ACE_Allocator::instance()->malloc(size); \
33  if (ptr == 0) { \
34  throw std::bad_alloc(); \
35  } \
36  return ptr; \
37  } \
38  \
39  void operator delete[](void* ptr) \
40  { ACE_Allocator::instance()->free(ptr); } \
41  \
42  void* operator new[](size_t size, const std::nothrow_t&) throw() \
43  { return ACE_Allocator::instance()->malloc(size); } \
44  \
45  void operator delete[](void* ptr, const std::nothrow_t&) \
46  { ACE_Allocator::instance()->free(ptr); } \
47 
48 
49 #define OPENDDS_POOL_ALLOCATION_FWD \
50  using PoolAllocationBase::operator new; \
51  using PoolAllocationBase::operator new[]; \
52  using PoolAllocationBase::operator delete; \
53  using PoolAllocationBase::operator delete[]; \
54 
56 
57 namespace OpenDDS {
58 namespace DCPS {
59 
61 {
62 public:
64 };
65 
66 }
67 }
68 
70 
71 #endif /* dds_DCPS_PoolAllocationBase_h */
#define OPENDDS_POOL_ALLOCATION_HOOKS
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28