Skip to content

Commit

Permalink
Fix MemoryPoolAllocator::Clear() to clear user-buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed May 14, 2015
1 parent 1034587 commit 0691502
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/rapidjson/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ class MemoryPoolAllocator {

//! Deallocates all memory chunks, excluding the user-supplied buffer.
void Clear() {
while(chunkHead_ != 0 && chunkHead_ != userBuffer_) {
while (chunkHead_ && chunkHead_ != userBuffer_) {
ChunkHeader* next = chunkHead_->next;
baseAllocator_->Free(chunkHead_);
chunkHead_ = next;
}
if (chunkHead_ && chunkHead_ == userBuffer_)
chunkHead_->size = 0; // Clear user buffer
}

//! Computes the total capacity of allocated memory chunks.
Expand Down

0 comments on commit 0691502

Please sign in to comment.