]> granicus.if.org Git - graphviz/commitdiff
neatogen new_array: 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 6ea155d476d7db5613add14883b7bcf9d33c7dfb..bb892b7df4c368f91c8b512518b292585547ec55 100644 (file)
@@ -10,7 +10,7 @@
 
 
 #include "config.h"
-
+#include       <cgraph/alloc.h>
 #include       <neatogen/neato.h>
 #include       <neatogen/stress.h>
 #include       <time.h>
@@ -44,12 +44,10 @@ static double distvec(double *p0, double *p1, double *vec)
 
 double **new_array(int m, int n, double ival)
 {
-    double **rv;
-    double *mem;
     int i, j;
 
-    rv = N_NEW(m, double *);
-    mem = N_NEW(m * n, double);
+    double **rv = gv_calloc(m, sizeof(double*));
+    double *mem = gv_calloc(m * n, sizeof(double));
     for (i = 0; i < m; i++) {
        rv[i] = mem;
        mem += n;