22 #ifndef COMMON_MEMORYPOOL_H 23 #define COMMON_MEMORYPOOL_H 25 #include "common/scummsys.h" 26 #include "common/array.h" 59 const size_t _chunkSize;
62 size_t _chunksPerPage;
65 void addPageToPool(
const Page &page);
66 bool isPointerInPage(
void *ptr,
const Page &page);
111 template<
size_t CHUNK_SIZE,
size_t NUM_INTERNAL_CHUNKS = 32>
115 REAL_CHUNK_SIZE = (CHUNK_SIZE +
sizeof(
void *) - 1) & (~(
sizeof(
void *) - 1))
118 byte _storage[NUM_INTERNAL_CHUNKS * REAL_CHUNK_SIZE];
121 assert(REAL_CHUNK_SIZE == _chunkSize);
123 Page internalPage = { _storage, NUM_INTERNAL_CHUNKS };
124 addPageToPool(internalPage);
129 template<
size_t CHUNK_SIZE>
138 template<
class T,
size_t NUM_INTERNAL_CHUNKS = 32>
164 assert(nbytes <= pool.getChunkSize());
165 return pool.allocChunk();
void freeChunk(void *ptr)
Definition: memorypool.h:49
Definition: memorypool.h:112
size_t getChunkSize() const
Definition: memorypool.h:103
void deleteChunk(T *ptr)
Definition: memorypool.h:145
Definition: algorithm.h:29
Definition: memorypool.h:139
Definition: memorypool.h:54