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.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h
index 6dfa85ae..1db5a1be 100644
--- a/include/rapidjson/allocators.h
+++ b/include/rapidjson/allocators.h
@@ -43,7 +43,7 @@ concept Allocator {
//! C-runtime library allocator.
/*! This class is just wrapper for standard C library memory routines.
- \implements Allocator
+ \note implements Allocator concept
*/
class CrtAllocator {
public:
@@ -70,7 +70,7 @@ public:
The user-buffer is not deallocated by this allocator.
\tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator.
- \implements Allocator
+ \note implements Allocator concept
*/
template <typename BaseAllocator = CrtAllocator>
class MemoryPoolAllocator {
@@ -99,12 +99,12 @@ public:
\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.
\param baseAllocator The allocator for allocating memory chunks.
*/
- MemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
+ MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0)
{
RAPIDJSON_ASSERT(buffer != 0);
RAPIDJSON_ASSERT(size > sizeof(ChunkHeader));
- chunkHead_ = (ChunkHeader*)buffer;
+ chunkHead_ = reinterpret_cast<ChunkHeader *>(buffer);
chunkHead_->capacity = size - sizeof(ChunkHeader);
chunkHead_->size = 0;
chunkHead_->next = 0;
@@ -120,7 +120,7 @@ public:
//! Deallocates all memory chunks, excluding the user-supplied buffer.
void Clear() {
- while(chunkHead_ != 0 && chunkHead_ != (ChunkHeader *)userBuffer_) {
+ while(chunkHead_ != 0 && chunkHead_ != userBuffer_) {
ChunkHeader* next = chunkHead_->next;
baseAllocator_->Free(chunkHead_);
chunkHead_ = next;
@@ -153,7 +153,7 @@ public:
if (chunkHead_->size + size > chunkHead_->capacity)
AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);
- char *buffer = (char *)(chunkHead_ + 1) + chunkHead_->size;
+ void *buffer = reinterpret_cast<char *>(chunkHead_ + 1) + chunkHead_->size;
chunkHead_->size += size;
return buffer;
}
@@ -169,7 +169,7 @@ public:
// Simply expand it if it is the last allocation and there is sufficient space
if (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) {
- size_t increment = newSize - originalSize;
+ size_t increment = static_cast<size_t>(newSize - originalSize);
increment = RAPIDJSON_ALIGN(increment);
if (chunkHead_->size + increment <= chunkHead_->capacity) {
chunkHead_->size += increment;
@@ -211,7 +211,7 @@ private:
ChunkHeader *chunkHead_; //!< Head of the chunk linked-list. Only the head chunk serves allocation.
size_t chunk_capacity_; //!< The minimum capacity of chunk when they are allocated.
- char *userBuffer_; //!< User supplied buffer.
+ void *userBuffer_; //!< User supplied buffer.
BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks.
BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object.
};