]> granicus.if.org Git - graphviz/commitdiff
neatogen scan_graph_mode: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 26 Dec 2022 05:41:23 +0000 (21:41 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 29 Jan 2023 21:27:37 +0000 (13:27 -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/stuff.c

index 1cdfa208cde5728d29adcb2b04206097f63cfbf7..d1ac1bc9974def246c1235df6bb38a88eb19d845 100644 (file)
@@ -250,7 +250,7 @@ int scan_graph_mode(graph_t * G, int mode)
            Damping = atof(str);
        else
            Damping = .99;
-       GD_neato_nlist(G) = N_NEW(nV + 1, node_t *);
+       GD_neato_nlist(G) = gv_calloc(nV + 1, sizeof(node_t*));
        for (i = 0, np = agfstnode(G); np; np = agnxtnode(G, np)) {
            GD_neato_nlist(G)[i] = np;
            ND_id(np) = i++;
@@ -260,7 +260,7 @@ int scan_graph_mode(graph_t * G, int mode)
     } else if (mode == MODE_SGD) {
        Epsilon = .01;
        getdouble(G, "epsilon", &Epsilon);
-       GD_neato_nlist(G) = N_NEW(nV + 1, node_t *); // not sure why but sometimes needs the + 1
+       GD_neato_nlist(G) = gv_calloc(nV + 1, sizeof(node_t*)); // not sure why but sometimes needs the + 1
        for (i = 0, np = agfstnode(G); np; np = agnxtnode(G, np)) {
            GD_neato_nlist(G)[i] = np;
            ND_id(np) = i++;