From fe1cec5655bd82da73312fac5f5e1aab3cfe5c65 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 17 Nov 2022 17:14:41 -0800 Subject: [PATCH] neatogen mkTriGraph: use cgraph wrapper 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. Note that in this change we can drop some explicit initialization because the cgraph wrappers zero-initialize. --- lib/neatogen/multispline.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/neatogen/multispline.c b/lib/neatogen/multispline.c index 6cc3a41ac..d3ba4bee3 100644 --- a/lib/neatogen/multispline.c +++ b/lib/neatogen/multispline.c @@ -565,7 +565,6 @@ static void freeTriGraph(tgraph * tg) */ static tgraph *mkTriGraph(surface_t * sf, int maxv, pointf * pts) { - tgraph *g; tnode *np; int j, i, ne = 0; int *jp; @@ -575,28 +574,16 @@ static tgraph *mkTriGraph(surface_t * sf, int maxv, pointf * pts) if (sf->neigh[i] != -1) ne++; - g = GNEW(tgraph); + tgraph *g = gv_alloc(sizeof(tgraph)); /* plus 2 for nodes added as endpoints of an edge */ g->nnodes = sf->nfaces + 2; - g->nodes = N_GNEW(g->nnodes, tnode); - - g->edges = NULL; - g->nedges = 0; + g->nodes = gv_calloc(g->nnodes, sizeof(tnode)); for (i = 0; i < sf->nfaces; i++) { np = g->nodes + i; - np->ne = 0; - np->edges = NULL; np->ctr = triCenter(pts, sf->faces + 3 * i); } - /* initialize variable nodes */ - np = g->nodes + i; - np->ne = 0; - np->edges = NULL; - np++; - np->ne = 0; - np->edges = NULL; for (i = 0; i < sf->nfaces; i++) { np = g->nodes + i; -- 2.50.1