From c61815f270dd6dacd8d2b7444b295735066dca57 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 20 Sep 2022 19:31:18 -0700 Subject: [PATCH] pack pccomps: 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/pack/ccomps.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pack/ccomps.c b/lib/pack/ccomps.c index 3cffd5937..403897024 100644 --- a/lib/pack/ccomps.c +++ b/lib/pack/ccomps.c @@ -153,7 +153,6 @@ Agraph_t **pccomps(Agraph_t * g, int *ncc, char *pfx, bool *pinned) char *name; Agraph_t *out = NULL; Agnode_t *n; - Agraph_t **ccs; size_t len; size_t bnd = 10; bool pin = false; @@ -166,7 +165,7 @@ Agraph_t **pccomps(Agraph_t * g, int *ncc, char *pfx, bool *pinned) } name = setPrefix (pfx, &len, buffer, SMALLBUF); - ccs = N_GNEW(bnd, Agraph_t *); + Agraph_t **ccs = gv_calloc(bnd, sizeof(Agraph_t*)); initStk(&stk, insertFn, markFn); for (n = agfstnode(g); n; n = agnxtnode(g, n)) @@ -202,8 +201,8 @@ Agraph_t **pccomps(Agraph_t * g, int *ncc, char *pfx, bool *pinned) goto packerror; } if (c_cnt == bnd) { + ccs = gv_recalloc(ccs, bnd, bnd * 2, sizeof(Agraph_t*)); bnd *= 2; - ccs = RALLOC(bnd, ccs, Agraph_t *); } ccs[c_cnt] = out; c_cnt++; @@ -221,7 +220,7 @@ packerror: ccs = NULL; } else { - ccs = RALLOC(c_cnt, ccs, Agraph_t *); + ccs = gv_recalloc(ccs, bnd, c_cnt, sizeof(Agraph_t*)); *ncc = (int) c_cnt; *pinned = pin; } -- 2.40.0