blob: 51c5a8e50b6fd8b90ff00c72d7187305e1cedc34 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#pragma once
#include <memory>
template <class Allocator, class T>
using TReboundAllocator = typename std::allocator_traits<Allocator>::template rebind_alloc<T>;
class IAllocator {
public:
struct TBlock {
void* Data;
size_t Len;
};
virtual ~IAllocator() = default;
virtual TBlock Allocate(size_t len) = 0;
virtual void Release(const TBlock& block) = 0;
};
class TDefaultAllocator: public IAllocator {
public:
TBlock Allocate(size_t len) override;
void Release(const TBlock& block) override;
static IAllocator* Instance() noexcept;
};
|