]> granicus.if.org Git - graphviz/commitdiff
circogen find_pair_edges: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 20 Nov 2022 20:02:53 +0000 (12:02 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 24 Nov 2022 22:45:25 +0000 (14:45 -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/circogen/blockpath.c

index 366e1cd608c65e3ad7c630fe9e19669edf99fd89..ee91d462a4b950892f67e3cc0b3d9d4547709095 100644 (file)
@@ -8,7 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
-
+#include       <cgraph/alloc.h>
 #include       <circogen/blockpath.h>
 #include       <circogen/edgelist.h>
 #include       <circogen/deglist.h>
@@ -84,9 +84,6 @@ static deglist_t *getList(Agraph_t * g)
  */
 static void find_pair_edges(Agraph_t * g, Agnode_t * n, Agraph_t * outg)
 {
-    Agnode_t **neighbors_with;
-    Agnode_t **neighbors_without;
-
     Agedge_t *e;
     Agedge_t *ep;
     Agedge_t *ex;
@@ -100,8 +97,8 @@ static void find_pair_edges(Agraph_t * g, Agnode_t * n, Agraph_t * outg)
     int edge_cnt = 0;
 
     node_degree = DEGREE(n);
-    neighbors_with = N_GNEW(node_degree, Agnode_t *);
-    neighbors_without = N_GNEW(node_degree, Agnode_t *);
+    Agnode_t **neighbors_with = gv_calloc(node_degree, sizeof(Agnode_t*));
+    Agnode_t **neighbors_without = gv_calloc(node_degree, sizeof(Agnode_t*));
 
     for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
        n1 = aghead(e);