Fix memory leak when iterating path
This commit is contained in:
@@ -42,6 +42,16 @@ void bzObjectPoolDestroy(BzObjectPool *pool) {
|
||||
bzFree(pool);
|
||||
}
|
||||
|
||||
size_t bzObjectPoolCalcNumFree(BzObjectPool *pool) {
|
||||
size_t count = 0;
|
||||
i32 idx = pool->firstFree;
|
||||
while (idx != -1) {
|
||||
count++;
|
||||
i32 *object = bzObjectPoolGetObject(pool, idx);
|
||||
idx = *object;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
void *bzObjectPool(BzObjectPool *pool) {
|
||||
if (pool->firstFree == -1)
|
||||
return NULL;
|
||||
|
||||
@@ -13,6 +13,7 @@ typedef struct BzObjectPoolDesc {
|
||||
BzObjectPool *bzObjectPoolCreate(const BzObjectPoolDesc *desc);
|
||||
void bzObjectPoolDestroy(BzObjectPool *pool);
|
||||
|
||||
size_t bzObjectPoolCalcNumFree(BzObjectPool *pool);
|
||||
void *bzObjectPool(BzObjectPool *pool);
|
||||
void *bzObjectPoolGetObject(BzObjectPool *pool, i32 idx);
|
||||
i32 bzObjectPoolGetIdx(BzObjectPool *pool, void *object);
|
||||
|
||||
Reference in New Issue
Block a user