From 194a14408a14dc036e6935dacce78cf274f88242 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez <matthew.fernandez@gmail.com> Date: Sat, 3 Sep 2022 11:13:16 -0700 Subject: [PATCH] ortho mkMazeGraph: use cgraph wrappers for allocation The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h wrappers except (1) they are header-only and (2) they live in a directory (cgraph) that is at the root of the dependency tree. The long term plan is to replace all use of lib/common/memory.h with lib/cgraph/alloc.h. --- lib/ortho/maze.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ortho/maze.c b/lib/ortho/maze.c index 78d7073ff..2dc1c921c 100644 --- a/lib/ortho/maze.c +++ b/lib/ortho/maze.c @@ -13,6 +13,7 @@ #define DEBUG +#include <cgraph/alloc.h> #include <math.h> #include <stdbool.h> #include <stddef.h> @@ -347,14 +348,14 @@ mkMazeGraph (maze* mp, boxf bb) sgraph* g = createSGraph (bound + 2); Dt_t* vdict = dtopen(&vdictDisc,Dtoset); Dt_t* hdict = dtopen(&hdictDisc,Dtoset); - snodeitem* ditems = N_NEW(bound, snodeitem); + snodeitem* ditems = gv_calloc(bound, sizeof(snodeitem)); snode** sides; /* For each cell, create if necessary and attach a node in search * corresponding to each internal face. The node also gets * a pointer to the cell. */ - sides = N_NEW(4*mp->ncells, snode*); + sides = gv_calloc(4 * mp->ncells, sizeof(snode*)); for (i = 0; i < mp->ncells; i++) { cell* cp = mp->cells+i; snode* np; @@ -392,7 +393,7 @@ mkMazeGraph (maze* mp, boxf bb) * connect it to its corresponding search nodes. */ maxdeg = 0; - sides = N_NEW(g->nnodes, snode*); + sides = gv_calloc(g->nnodes, sizeof(snode*)); nsides = 0; for (i = 0; i < mp->ngcells; i++) { cell* cp = mp->gcells+i; -- 2.40.0