]> granicus.if.org Git - graphviz/commitdiff
gvpack: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Sep 2022 04:13:13 +0000 (21:13 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 3 Oct 2022 00:31:38 +0000 (17:31 -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.

cmd/tools/gvpack.cpp

index 2231e9f9607a2b8ce4038164a9160eab698e3dda..3b023e914cc34315c889baab55cf4216fffb0e0d 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <assert.h>
 #include <gvc/gvc.h>
+#include <cgraph/alloc.h>
 #include <cgraph/exit.h>
 #include <common/render.h>
 #include <neatogen/neatoprocs.h>
@@ -545,7 +546,7 @@ static void cloneClusterTree(Agraph_t * g, Agraph_t * ng)
 
     if (GD_n_cluster(g)) {
        GD_n_cluster(ng) = GD_n_cluster(g);
-       GD_clust(ng) = N_NEW(1 + GD_n_cluster(g), Agraph_t *);
+       GD_clust(ng) = reinterpret_cast<Agraph_t**>(gv_calloc(1 + GD_n_cluster(g), sizeof(Agraph_t*)));
        for (i = 1; i <= GD_n_cluster(g); i++) {
            Agraph_t *c = GETCLUST(GD_clust(g)[i]);
            GD_clust(ng)[i] = c;
@@ -621,7 +622,7 @@ static Agraph_t *cloneGraph(std::vector<Agraph_t*> &gs, GVC_t *gvc) {
     /* set up cluster tree */
     if (GD_n_cluster(root)) {
        int j, idx;
-       GD_clust(root) = N_NEW(1 + GD_n_cluster(root), graph_t *);
+       GD_clust(root) = reinterpret_cast<graph_t**>(gv_calloc(1 + GD_n_cluster(root), sizeof(graph_t*)));
 
        idx = 1;
        for (Agraph_t *g : gs) {