1 #ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED 2 #define JSONCPP_BATCHALLOCATOR_H_INCLUDED 7 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 23 template <
typename AllocatedType, const
unsigned int objectPerAllocation>
26 typedef AllocatedType
Type;
30 assert(
sizeof(AllocatedType) * objectPerAllocation >=
31 sizeof(AllocatedType *));
32 assert(objectsPerPage >= 16);
88 AllocatedType
buffer_[objectPerAllocation];
92 const unsigned int mallocSize =
sizeof(
BatchInfo) -
sizeof(AllocatedType) * objectPerAllocation +
93 sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
110 #endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION 112 #endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
AllocatedType * allocate()
unsigned int objectsPerPage_
void free(void *ptr) noexcept
BatchAllocator(unsigned int objectsPerPage=255)
void operator=(const BatchAllocator &)=delete
static BatchInfo * allocateBatch(unsigned int objectsPerPage)
JSON (JavaScript Object Notation).
void * malloc(size_t size) noexcept
AllocatedType buffer_[objectPerAllocation]
void release(AllocatedType *object)
BatchInfo * currentBatch_
AllocatedType * freeHead_
Head of a single linked list within the allocated space of freeed object.