Skip to content

Commit 6f58746

Browse files
committed
Added macro RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY to allow default chunk capacity to be lowered for embedded devices with < 64k stack sizes
1 parent 8022a5f commit 6f58746

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

include/rapidjson/allocators.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ concept Allocator {
5252
\endcode
5353
*/
5454

55+
56+
/*! \def RAPIDJSON_ALLOCATOR_DEFUALT_CHUNK_CAPACITY
57+
\ingroup RAPIDJSON_CONFIG
58+
\brief User-defined kDefaultChunkCapacity definition.
59+
60+
User can define this as any \c size that is a power of 2.
61+
*/
62+
63+
#ifndef RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY
64+
#define RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY (64 * 1024)
65+
#endif
66+
67+
5568
///////////////////////////////////////////////////////////////////////////////
5669
// CrtAllocator
5770

@@ -248,7 +261,7 @@ class MemoryPoolAllocator {
248261
return false;
249262
}
250263

251-
static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity.
264+
static const int kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY; //!< Default chunk capacity.
252265

253266
//! Chunk header for perpending to each chunk.
254267
/*! Chunks are stored as a singly linked list.

0 commit comments

Comments
 (0)