Creates a new chunk. ! \param capacity Capacity of the chunk in bytes. \return true if success. */
| 257 | \return true if success. |
| 258 | */ |
| 259 | bool AddChunk(size_t capacity) { |
| 260 | if (!baseAllocator_) |
| 261 | ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator()); |
| 262 | if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) { |
| 263 | chunk->capacity = capacity; |
| 264 | chunk->size = 0; |
| 265 | chunk->next = chunkHead_; |
| 266 | chunkHead_ = chunk; |
| 267 | return true; |
| 268 | } |
| 269 | else |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity. |
| 274 |