MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / ObjectPool_New

Function ObjectPool_New

src/util/object_pool/object_pool.c:82–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82ObjectPool *ObjectPool_New(uint64_t itemCap, uint itemSize, void (*fp)(void *)) {
83 ObjectPool *pool = rm_malloc(sizeof(ObjectPool));
84 pool->itemCount = 0;
85 pool->itemSize = itemSize + HEADER_SIZE; // Add extra space to accommodate the item's header.
86 pool->blockCount = 0;
87 pool->blocks = NULL;
88 pool->deletedIdx = array_new(uint64_t, 128);
89 pool->destructor = fp;
90 _ObjectPool_AddBlocks(pool, ITEM_COUNT_TO_BLOCK_COUNT(itemCap));
91 return pool;
92}
93
94void *ObjectPool_NewItem(ObjectPool *pool) {
95 // Reuse a deleted item if one is available.

Callers 4

test_objectPoolNewFunction · 0.85
test_objectPoolAddItemFunction · 0.85

Calls 2

rm_mallocFunction · 0.85
_ObjectPool_AddBlocksFunction · 0.85

Tested by 3

test_objectPoolNewFunction · 0.68
test_objectPoolAddItemFunction · 0.68