ROSE  0.11.145.0
DefaultAllocator.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_DefaultAllocator_H
9 #define Sawyer_DefaultAllocator_H
10 
11 #include <cstddef>
12 #include <Sawyer/Sawyer.h>
13 
14 namespace Sawyer {
15 
21 public:
27  void *allocate(size_t size) { // hot
28  return ::operator new(size);
29  }
30 
36  void deallocate(void *addr, size_t size) { // hot
37  SAWYER_ARGUSED(size);
38  ::operator delete(addr);
39  }
40 };
41 
59 template<class Allocator>
61  Allocator &allocator_;
62 public:
67  ProxyAllocator(Allocator &allocator): allocator_(allocator) {} // implicit
68 
74  void *allocate(size_t size) { return allocator_.allocate(size); }
75 
81  void deallocate(void *addr, size_t size) { allocator_.deallocate(addr, size); }
82 };
83 
84 } // namespace
85 
86 #endif
Allocator proxy.
void deallocate(void *addr, size_t size)
Deallocate memory.
ProxyAllocator(Allocator &allocator)
Constructor.
Default allocator.
Name space for the entire library.
Definition: FeasiblePath.h:767
void deallocate(void *addr, size_t size)
Deallocate memory.
void * allocate(size_t size)
Allocate memory.
void * allocate(size_t size)
Allocate memory.