]> git.sesse.net Git - remoteglot-book/blob - arena.h
Fix move numbering when navigating in history.
[remoteglot-book] / arena.h
1 #ifndef _ARENA_H
2 #define _ARENA_H
3
4 // A simple arena for allocating lots of short strings.
5
6 class Arena {
7 public:
8         Arena();
9         ~Arena();
10
11         char *alloc(size_t bytes);
12
13 private:
14         static constexpr size_t BLOCK_SIZE = 1048576;
15
16         struct Block {
17                 char *memory;
18                 size_t used;
19                 Block *next;
20         };
21         Block *first;
22 };
23
24 #endif  // _ARENA_H