]> git.localhorst.tv Git - l2e.git/blob - src/loader/PagedAllocator.h
Merge branch 'master' into menus
[l2e.git] / src / loader / PagedAllocator.h
1 /*
2  * PagedAllocator.h
3  *
4  *  Created on: Oct 9, 2012
5  *      Author: holy
6  */
7
8 #ifndef LOADER_PAGEDALLOCATOR_H_
9 #define LOADER_PAGEDALLOCATOR_H_
10
11 #include <deque>
12
13 namespace loader {
14
15 class PagedAllocator {
16
17 public:
18         explicit PagedAllocator(unsigned int pageSize);
19         ~PagedAllocator();
20 private:
21         PagedAllocator(const PagedAllocator &);
22         PagedAllocator &operator =(const PagedAllocator &);
23
24 public:
25         char *Alloc(unsigned int size);
26
27 private:
28         unsigned int Free() const;
29         void NewPage();
30         char *CurrentPage();
31         const char *CurrentPage() const;
32
33 private:
34         char *head;
35         std::deque<char *> pages;
36         const unsigned int pageSize;
37
38 };
39
40 }
41
42 #endif /* LOADER_PAGEDALLOCATOR_H_ */