From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: patchwork tree_map: use cgraph wrapper for allocation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c1eaaf0d1914fe4458a334a680f54e116071675;p=graphviz patchwork tree_map: 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. --- diff --git a/lib/patchwork/tree_map.c b/lib/patchwork/tree_map.c index 78c5f484f..2dfd4ec99 100644 --- a/lib/patchwork/tree_map.c +++ b/lib/patchwork/tree_map.c @@ -8,6 +8,7 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ +#include #include #include #include @@ -98,7 +99,6 @@ static void squarify(int n, double *area, rectangle *recs, int nadded, double ma */ rectangle* tree_map(int n, double *area, rectangle fillrec){ /* fill a rectangle rec with n items, each item i has area[i] area. */ - rectangle *recs; int i; double total = 0, minarea = 1., maxarea = 0., asp = 1, totalarea = 0; int nadded = 0; @@ -108,7 +108,7 @@ rectangle* tree_map(int n, double *area, rectangle fillrec){ if (total > fillrec.size[0] * fillrec.size[1] + 0.001) return NULL; - recs = N_NEW(n,rectangle); + rectangle *recs = gv_calloc(n, sizeof(rectangle)); squarify(n, area, recs, nadded, maxarea, minarea, totalarea, asp, fillrec); return recs; }