Fix memory leak when iterating path

This commit is contained in:
2023-11-23 19:35:59 +01:00
parent a17450dd81
commit 6e977b7433
6 changed files with 17 additions and 2 deletions

View File

@@ -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;

View File

@@ -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);