--- /dev/null
+#include <stdlib.h>
+#include <assert.h>
+#include "arena.h"
+
+Arena::Arena() : first(NULL) {}
+
+Arena::~Arena()
+{
+ Block *next;
+ for (Block *b = first; b != NULL; b = next) {
+ delete[] b->memory;
+
+ next = b->next;
+ delete b;
+ }
+}
+
+char *Arena::alloc(size_t bytes)
+{
+ assert(bytes < BLOCK_SIZE); // Can fix, but we don't need to.
+
+ if (first == NULL || first->used + bytes > BLOCK_SIZE) {
+ Block *b = new Block;
+ b->memory = new char[BLOCK_SIZE];
+ b->used = 0;
+ b->next = first;
+ first = b;
+ }
+
+ char *ret = first->memory + first->used;
+ first->used += bytes;
+ return ret;
+}