From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: neatogen mkRouter: use cgraph wrapper for allocation X-Git-Tag: 7.0.3~11^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ae2e28efc7b972c840ab1daa4d9330047cc374d;p=graphviz neatogen mkRouter: 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/neatogen/multispline.c b/lib/neatogen/multispline.c index d3ba4bee3..4f9d93bc0 100644 --- a/lib/neatogen/multispline.c +++ b/lib/neatogen/multispline.c @@ -614,25 +614,21 @@ void freeRouter(router_t * rtr) router_t *mkRouter(Ppoly_t** obsp, int npoly) { - router_t *rtr = NEW(router_t); + router_t *rtr = gv_alloc(sizeof(router_t)); Ppoly_t* obs; boxf bb; - pointf *pts; int npts; surface_t *sf; - int *segs; - double *x; - double *y; int maxv = 4; /* default max. no. of vertices in an obstacle; set below */ /* points in obstacle i have indices obsi[i] through obsi[i+1]-1 in pts */ - int *obsi = N_NEW(npoly + 1, int); + int *obsi = gv_calloc(npoly + 1, sizeof(int)); int i, j, ix = 4, six = 0; bb = bbox(obsp, npoly, &npts); npts += 4; /* 4 points of bounding box */ - pts = N_GNEW(npts, pointf); /* all points are stored in pts */ - segs = N_GNEW(2 * npts, int); /* indices of points forming segments */ + pointf *pts = gv_calloc(npts, sizeof(pointf)); // all points are stored in pts + int *segs = gv_calloc(2 * npts, sizeof(int)); // indices of points forming segments /* store bounding box in CCW order */ pts[0] = bb.LL; @@ -667,8 +663,8 @@ router_t *mkRouter(Ppoly_t** obsp, int npoly) obsi[i] = ix; /* copy points into coordinate arrays */ - x = N_GNEW(npts, double); - y = N_GNEW(npts, double); + double *x = gv_calloc(npts, sizeof(double)); + double *y = gv_calloc(npts, sizeof(double)); for (i = 0; i < npts; i++) { x[i] = pts[i].x; y[i] = pts[i].y;