diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h index efc4a30..b12c31b 100644 --- a/include/rapidjson/allocators.h +++ b/include/rapidjson/allocators.h @@ -130,7 +130,7 @@ public: //! Computes the total capacity of allocated memory chunks. /*! \return total capacity in bytes. */ - size_t Capacity() { + size_t Capacity() const { size_t capacity = 0; for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) capacity += c->capacity; @@ -140,7 +140,7 @@ public: //! Computes the memory blocks allocated. /*! \return total used bytes. */ - size_t Size() { + size_t Size() const { size_t size = 0; for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) size += c->size; @@ -196,7 +196,7 @@ private: /*! \param capacity Capacity of the chunk in bytes. */ void AddChunk(size_t capacity) { - ChunkHeader* chunk = (ChunkHeader*)baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity); + ChunkHeader* chunk = reinterpret_cast(baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity)); chunk->capacity = capacity; chunk->size = 0; chunk->next = chunkHead_; diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index d351fce..bc2d836 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -518,12 +518,12 @@ public: if (o.size >= o.capacity) { if (o.capacity == 0) { o.capacity = kDefaultObjectCapacity; - o.members = (Member*)allocator.Malloc(o.capacity * sizeof(Member)); + o.members = reinterpret_cast(allocator.Malloc(o.capacity * sizeof(Member))); } else { SizeType oldCapacity = o.capacity; o.capacity *= 2; - o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member)); + o.members = reinterpret_cast(allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member))); } } o.members[o.size].name.RawAssign(name);