]> git.localhorst.tv Git - l2e.git/blob - src/loader/PagedAllocator.h
new object file format in compiler
[l2e.git] / src / loader / PagedAllocator.h
1 #ifndef LOADER_PAGEDALLOCATOR_H_
2 #define LOADER_PAGEDALLOCATOR_H_
3
4 #include <deque>
5
6 namespace loader {
7
8 class PagedAllocator {
9
10 public:
11         explicit PagedAllocator(unsigned int pageSize);
12         ~PagedAllocator();
13 private:
14         PagedAllocator(const PagedAllocator &);
15         PagedAllocator &operator =(const PagedAllocator &);
16
17 public:
18         char *Alloc(unsigned int size);
19
20         unsigned int PageOf(void *) const;
21         unsigned int PageOffsetOf(void *) const;
22
23 private:
24         unsigned int Free() const;
25         void NewPage();
26         char *CurrentPage();
27         const char *CurrentPage() const;
28
29 private:
30         char *head;
31         std::deque<char *> pages;
32         const unsigned int pageSize;
33
34 };
35
36 }
37
38 #endif