4 * Created on: Oct 9, 2012
8 #include "PagedAllocator.h"
14 PagedAllocator::PagedAllocator(unsigned int pageSize)
16 , pageSize(pageSize) {
20 PagedAllocator::~PagedAllocator() {
21 for (deque<char *>::const_iterator i(pages.begin()), end(pages.end()); i != end; ++i) {
27 char *PagedAllocator::Alloc(unsigned int size) {
28 if (size > pageSize) {
29 char *page(new char[size]);
30 pages.push_front(page);
33 unsigned int free(Free());
42 unsigned int PagedAllocator::Free() const {
43 return pageSize - (head - CurrentPage());
46 void PagedAllocator::NewPage() {
47 char *page(new char[pageSize]);
48 pages.push_back(page);
52 char *PagedAllocator::CurrentPage() {
56 const char *PagedAllocator::CurrentPage() const {