Allocate path with object pool for pathfinding
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "breeze/utils/array.h"
|
||||
#include "breeze/utils/heap.h"
|
||||
#include "breeze/utils/object_pool.h"
|
||||
#include "breeze/utils/string.h"
|
||||
#include "breeze/utils/tokenizer.h"
|
||||
|
||||
|
||||
@@ -21,9 +21,10 @@ typedef double f64;
|
||||
|
||||
#define BZ_ASSERT(e) assert(e)
|
||||
|
||||
#define DEBUG_MODE
|
||||
#ifndef DEBUG_MODE
|
||||
#undef BZ_ASSERT
|
||||
#define BZ_ASSERT(e) (void)(e)
|
||||
#define BZ_ASSERT(e) BZ_UNUSDE(x)
|
||||
#endif
|
||||
|
||||
#define BZ_UNUSED(x) (void)(x)
|
||||
|
||||
@@ -54,8 +54,9 @@ void *bzObjectPool(BzObjectPool *pool) {
|
||||
return object;
|
||||
}
|
||||
void bzObjectPoolRelease(BzObjectPool *pool, void *object) {
|
||||
size_t objectIdx = (size_t) object - (size_t)pool->objects;
|
||||
size_t objectIdx = (size_t) object - (size_t) pool->objects;
|
||||
objectIdx /= pool->stride;
|
||||
BZ_ASSERT(objectIdx < pool->numObjects);
|
||||
*(i32 *) objectIdx = pool->firstFree;
|
||||
*(i32 *) ((u8 *) pool->objects + objectIdx * pool->stride) = pool->firstFree;
|
||||
pool->firstFree = (i32) objectIdx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user