]> granicus.if.org Git - graphviz/commitdiff
dotgen computeNodeGroups: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 14 Sep 2022 01:23:36 +0000 (18:23 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 14 Sep 2022 01:39:06 +0000 (18:39 -0700)
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/dotgen/aspect.c

index 9d09e30f14cbae051d93bfd6e0ae9c97a03f4569..ae67a7923ebe55fb2fc3be8921ecb40a1d855c1c 100644 (file)
@@ -9,6 +9,7 @@
  *************************************************************************/
 
 #include <assert.h>
+#include <cgraph/alloc.h>
 #include <cgraph/bitarray.h>
 #include <dotgen/dot.h>
 #include <stddef.h>
@@ -55,7 +56,7 @@ static void computeNodeGroups(graph_t * g)
 {
     node_t *n;
 
-    nodeGroups = N_GNEW(agnnodes(g), nodeGroup_t);
+    nodeGroups = gv_calloc(agnnodes(g), sizeof(nodeGroup_t));
 
     nNodeGroups = 0;
 
@@ -66,7 +67,7 @@ static void computeNodeGroups(graph_t * g)
 
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        if (ND_UF_size(n) == 0) {       /* no same ranking constraint */
-           nodeGroups[nNodeGroups].nodes = NEW(node_t *);
+           nodeGroups[nNodeGroups].nodes = gv_alloc(sizeof(node_t*));
            nodeGroups[nNodeGroups].nodes[0] = n;
            nodeGroups[nNodeGroups].nNodes = 1;
            nodeGroups[nNodeGroups].width = ND_width(n);
@@ -90,8 +91,7 @@ static void computeNodeGroups(graph_t * g)
                ND_id(n) = index;
            } else              /* create a new group */
            {
-               nodeGroups[nNodeGroups].nodes =
-                   N_NEW(ND_UF_size(l), node_t *);
+               nodeGroups[nNodeGroups].nodes = gv_calloc(ND_UF_size(l), sizeof(node_t*));
 
                if (l == n)     /* node n is the leader */
                {