ROSE 0.11.145.147
SmallObject.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_SmallObject_H
9#define Sawyer_SmallObject_H
10
11#include <Sawyer/PoolAllocator.h>
12#include <Sawyer/Sawyer.h>
13
14namespace Sawyer {
15
19class SAWYER_EXPORT SmallObject {
20#include <Sawyer/WarningsOff.h>
21 static SynchronizedPoolAllocator allocator_;
22#include <Sawyer/WarningsRestore.h>
23public:
25 static SynchronizedPoolAllocator& poolAllocator() { return allocator_; }
26
27 static void *operator new(size_t size) { return allocator_.allocate(size); }
28 static void operator delete(void *ptr, size_t size) { allocator_.deallocate(ptr, size); }
29};
30
31} // namespace
32#endif
Small object allocation from memory pools.
void * allocate(size_t size)
Allocate one object of specified size.
Small object support.
Definition SmallObject.h:19
static SynchronizedPoolAllocator & poolAllocator()
Return the pool allocator for this class.
Definition SmallObject.h:25
Sawyer support library.