Rename ...New/...Free to ...Create/...Destroy

This commit is contained in:
2023-11-16 06:26:24 +01:00
parent 581da2b990
commit 9e6c836207
11 changed files with 34 additions and 34 deletions

View File

@@ -15,14 +15,14 @@ EntityMap entityMapCreate(const EntityMapDesc *desc) {
size_t numBytes = sizeof(EntityMapCell) * map.width * map.height * map.cellDepth;
map.cells = bzAlloc(numBytes);
bzMemSet(map.cells, 0, numBytes);
map.entities = bzArrayNew(EntityMapEntry, 512);
map.entities = bzArrayCreate(EntityMapEntry, 512);
return map;
}
void entityMapDestroy(EntityMap *entityMap) {
bzFree(entityMap->cells);
entityMap->cells = NULL;
bzArrayFree(entityMap->entities);
bzArrayDestroy(entityMap->entities);
entityMap->entities = NULL;
}

View File

@@ -206,7 +206,7 @@ void render(float dt, void *userData) {
static PathNode *heap = NULL;
if (!heap)
heap = bzHeapNew(PathNode, game->map.width * game->map.height);
heap = bzHeapCreate(PathNode, game->map.width * game->map.height);
game->path.waypoints = game->waypoints;
game->path.maxWaypoints = 128;
findPath(&(PathfindingDesc) {

View File

@@ -26,7 +26,7 @@ bool findPath(const PathfindingDesc *desc) {
bzMemSet(visited, 0, sizeof(visited));
PathNode *heap = desc->heap;
if (!heap) heap = bzHeapNew(PathNode, map->width * map->height);
if (!heap) heap = bzHeapCreate(PathNode, map->width * map->height);
else bzHeapClear(heap);
i32 toTargetCost = dst(desc->start, desc->target);
@@ -115,7 +115,7 @@ bool findPath(const PathfindingDesc *desc) {
}
if (!desc->heap) {
bzHeapFree(heap);
bzHeapDestroy(heap);
heap = NULL;
}