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