]> granicus.if.org Git - graphviz/commitdiff
sparse SparseMatrix_distance_matrix_khops: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Sep 2022 01:14:34 +0000 (18:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 20 Sep 2022 14:36:59 +0000 (07:36 -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/sparse/SparseMatrix.c

index 922e30d3a001f4256efbe6e8a52fb6cbc05af198..c4b49208cf2efd5dfd8d4f1673344471357949a1 100644 (file)
@@ -13,7 +13,6 @@
 #include <math.h>
 #include <assert.h>
 #include <cgraph/alloc.h>
-#include <common/memory.h>
 #include <common/arith.h>
 #include <limits.h>
 #include <sparse/SparseMatrix.h>
@@ -2452,8 +2451,8 @@ SparseMatrix SparseMatrix_distance_matrix_khops(int khops, SparseMatrix D0, int
       }
      }
   } else {
-    list = MALLOC(sizeof(int)*n);
-    dist = MALLOC(sizeof(double)*n);
+    list = gv_calloc(n, sizeof(int));
+    dist = gv_calloc(n, sizeof(double));
     /*
     Dijkstra_khops(khops, D, 60, dist, &nlist, list, &dmax);
     for (j = 0; j < nlist; j++){