]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/PagedAllocator.h
better allocation in interpreter
[l2e.git] / src / loader / PagedAllocator.h
diff --git a/src/loader/PagedAllocator.h b/src/loader/PagedAllocator.h
new file mode 100644 (file)
index 0000000..48cda27
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * PagedAllocator.h
+ *
+ *  Created on: Oct 9, 2012
+ *      Author: holy
+ */
+
+#ifndef LOADER_PAGEDALLOCATOR_H_
+#define LOADER_PAGEDALLOCATOR_H_
+
+#include <deque>
+
+namespace loader {
+
+class PagedAllocator {
+
+public:
+       explicit PagedAllocator(unsigned int pageSize);
+       ~PagedAllocator();
+private:
+       PagedAllocator(const PagedAllocator &);
+       PagedAllocator &operator =(const PagedAllocator &);
+
+public:
+       char *Alloc(unsigned int size);
+
+private:
+       unsigned int Free() const;
+       void NewPage();
+       char *CurrentPage();
+       const char *CurrentPage() const;
+
+private:
+       char *head;
+       std::deque<char *> pages;
+       const unsigned int pageSize;
+
+};
+
+}
+
+#endif /* LOADER_PAGEDALLOCATOR_H_ */