ROSE 0.11.145.147
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://gitlab.com/charger7534/sawyer.git.
4
5
6
7
8#ifndef Sawyer_DefaultAllocator_H
9#define Sawyer_DefaultAllocator_H
10
11#include <cstddef>
12#include <Sawyer/Sawyer.h>
13
14namespace Sawyer {
15
21public:
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
59template<class Allocator>
61 Allocator &allocator_;
62public:
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
void * allocate(size_t size)
Allocate memory.
void deallocate(void *addr, size_t size)
Deallocate memory.
void * allocate(size_t size)
Allocate memory.
void deallocate(void *addr, size_t size)
Deallocate memory.
ProxyAllocator(Allocator &allocator)
Constructor.
Sawyer support library.