Fix MemoryPoolAllocator::Clear() to clear user-buffer
This commit is contained in:
parent
01393e0145
commit
69414cb4d6
@ -143,11 +143,13 @@ public:
|
|||||||
|
|
||||||
//! Deallocates all memory chunks, excluding the user-supplied buffer.
|
//! Deallocates all memory chunks, excluding the user-supplied buffer.
|
||||||
void Clear() {
|
void Clear() {
|
||||||
while(chunkHead_ != 0 && chunkHead_ != userBuffer_) {
|
while (chunkHead_ && chunkHead_ != userBuffer_) {
|
||||||
ChunkHeader* next = chunkHead_->next;
|
ChunkHeader* next = chunkHead_->next;
|
||||||
baseAllocator_->Free(chunkHead_);
|
baseAllocator_->Free(chunkHead_);
|
||||||
chunkHead_ = next;
|
chunkHead_ = next;
|
||||||
}
|
}
|
||||||
|
if (chunkHead_ && chunkHead_ == userBuffer_)
|
||||||
|
chunkHead_->size = 0; // Clear user buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Computes the total capacity of allocated memory chunks.
|
//! Computes the total capacity of allocated memory chunks.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user