Destructor
| 80 | |
| 81 | // Destructor |
| 82 | PoolAllocator::~PoolAllocator() { |
| 83 | |
| 84 | // Release the memory allocated for each block |
| 85 | for (uint i=0; i<mNbCurrentMemoryBlocks; i++) { |
| 86 | mBaseAllocator.release(mMemoryBlocks[i].memoryUnits, BLOCK_SIZE); |
| 87 | } |
| 88 | |
| 89 | mBaseAllocator.release(mMemoryBlocks, mNbAllocatedMemoryBlocks * sizeof(MemoryBlock)); |
| 90 | |
| 91 | #ifndef NDEBUG |
| 92 | // Check that the allocate() and release() methods have been called the same |
| 93 | // number of times to avoid memory leaks. |
| 94 | assert(mNbTimesAllocateMethodCalled == 0); |
| 95 | #endif |
| 96 | |
| 97 | } |
| 98 | |
| 99 | // Allocate memory of a given size (in bytes) and return a pointer to the |
| 100 | // allocated memory. |