]> granicus.if.org Git - graphviz/commitdiff
neatogen makeObstacle: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 18 Nov 2022 01:14:41 +0000 (17:14 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 3 Dec 2022 21:07:21 +0000 (13:07 -0800)
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/neatogen/neatosplines.c

index 771ab97eb1ac5edfe918c4a6ad507fe7c6c913f5..cfeeb0c77497ec800c103b1c3bae3b113bf97e18 100644 (file)
@@ -292,7 +292,7 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
     switch (shapeOf(n)) {
     case SH_POLY:
     case SH_POINT:
-       obs = NEW(Ppoly_t);
+       obs = gv_alloc(sizeof(Ppoly_t));
        poly = ND_shape_info(n);
        if (isOrtho) {
            isPoly = 1;
@@ -334,7 +334,7 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
            adj = drand48() * .01;
        }
        obs->pn = sides;
-       obs->ps = N_NEW(sides, Ppoint_t);
+       obs->ps = gv_calloc(sides, sizeof(Ppoint_t));
        /* assuming polys are in CCW order, and pathplan needs CW */
        for (j = 0; j < sides; j++) {
            double xmargin = 0.0, ymargin = 0.0;
@@ -394,9 +394,9 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
     case SH_RECORD:
        fld = ND_shape_info(n);
        b = fld->b;
-       obs = NEW(Ppoly_t);
+       obs = gv_alloc(sizeof(Ppoly_t));
        obs->pn = 4;
-       obs->ps = N_NEW(4, Ppoint_t);
+       obs->ps = gv_calloc(4, sizeof(Ppoint_t));
        /* CW order */
        pt = ND_coord(n);
        if (pmargin->doAdd) {
@@ -413,9 +413,9 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
        }
        break;
     case SH_EPSF:
-       obs = NEW(Ppoly_t);
+       obs = gv_alloc(sizeof(Ppoly_t));
        obs->pn = 4;
-       obs->ps = N_NEW(4, Ppoint_t);
+       obs->ps = gv_calloc(4, sizeof(Ppoint_t));
        /* CW order */
        pt = ND_coord(n);
        if (pmargin->doAdd) {