-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackAllocator.h
More file actions
38 lines (32 loc) · 742 Bytes
/
Copy pathStackAllocator.h
File metadata and controls
38 lines (32 loc) · 742 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "Allocator.h"
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stddef.h>
#include <memory>
class StackAllocator : public Allocator {
public:
StackAllocator(size_t sz);
StackAllocator(void* buffer, size_t sz);
~StackAllocator();
void* Alloc(size_t sz, size_t alignment) final;
inline void Free(void*&) final;
inline void Release() final;
inline void Reset() final;
inline void ZeroMem() final;
inline void Layout() final;
protected:
struct AllocHeader {
uint8_t padding;
};
private:
void* m_start;
void* m_cur;
void* m_end;
size_t m_size;
size_t m_free;
bool m_initialized;
bool m_preAlloc;
};