From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: patchwork layoutTree: use cgraph wrappers for allocation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72aa6febc89f1a8436beaf22fa1c29c4fed03a69;p=graphviz patchwork layoutTree: 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. --- diff --git a/lib/patchwork/patchwork.c b/lib/patchwork/patchwork.c index 0988b6fff..2ee03ce21 100644 --- a/lib/patchwork/patchwork.c +++ b/lib/patchwork/patchwork.c @@ -143,8 +143,6 @@ static int nodecmp (treenode_t** p0, treenode_t** p1) static void layoutTree(treenode_t * tree) { rectangle *recs; - treenode_t** nodes; - double* areas_sorted; int i, nc; treenode_t* cp; @@ -152,7 +150,7 @@ static void layoutTree(treenode_t * tree) if (tree->n_children == 0) return; nc = tree->n_children; - nodes = N_NEW(nc, treenode_t*); + treenode_t** nodes = gv_calloc(nc, sizeof(treenode_t*)); cp = tree->leftchild; for (i = 0; i < nc; i++) { nodes[i] = cp; @@ -160,7 +158,7 @@ static void layoutTree(treenode_t * tree) } qsort (nodes, nc, sizeof(treenode_t*), (qsort_cmpf)nodecmp); - areas_sorted = N_NEW(nc,double); + double* areas_sorted = gv_calloc(nc, sizeof(double)); for (i = 0; i < nc; i++) { areas_sorted[i] = nodes[i]->area; }