Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'include/rapidjson/allocators.h')
-rw-r--r--include/rapidjson/allocators.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h
index b7042a53..f615ffd9 100644
--- a/include/rapidjson/allocators.h
+++ b/include/rapidjson/allocators.h
@@ -143,11 +143,13 @@ public:
//! 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.