blob: 7228212a138c5166ca1487e9e7e06f7895cc3dc7 (
plain)
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
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef ENGINE_SHARED_MEMHEAP_H
#define ENGINE_SHARED_MEMHEAP_H
class CHeap
{
struct CChunk
{
char *m_pMemory;
char *m_pCurrent;
char *m_pEnd;
CChunk *m_pNext;
};
enum
{
// how large each chunk should be
CHUNK_SIZE = 1025*64,
};
CChunk *m_pCurrent;
void Clear();
void NewChunk();
void *AllocateFromChunk(unsigned int Size);
public:
CHeap();
~CHeap();
void Reset();
void *Allocate(unsigned Size);
};
#endif
|