]> granicus.if.org Git - graphviz/commitdiff
neatogen get_overlap_graph: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 7 Oct 2022 02:35:41 +0000 (19:35 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 11 Oct 2022 00:40:54 +0000 (17:40 -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/neatogen/overlap.c

index a4a56e000d5fa3d6563c42c7a6d558c679e53ff6..2c5cea6607fc07c41ef9ecd2f955bf714486d51d 100644 (file)
@@ -9,6 +9,7 @@
  *************************************************************************/
 
 #include "config.h"
+#include <cgraph/alloc.h>
 #include <neatogen/overlap.h>
 
 #if ((defined(HAVE_GTS) || defined(HAVE_TRIANGLE)) && defined(SFDP))
@@ -125,7 +126,6 @@ static void InfoDest(void *a){
 
 static SparseMatrix get_overlap_graph(int dim, int n, double *x, double *width, int check_overlap_only){
   /* if check_overlap_only = TRUE, we only check whether there is one overlap */
-  scan_point *scanpointsx, *scanpointsy;
   int i, k, neighbor;
   SparseMatrix A = NULL, B = NULL;
   rb_red_blk_node *newNode, *newNode0, *newNode2 = NULL;
@@ -134,7 +134,7 @@ static SparseMatrix get_overlap_graph(int dim, int n, double *x, double *width,
 
   A = SparseMatrix_new(n, n, 1, MATRIX_TYPE_REAL, FORMAT_COORD);
 
-  scanpointsx = N_GNEW(2*n,scan_point);
+  scan_point *scanpointsx = gv_calloc(2 * n, sizeof(scan_point));
   for (i = 0; i < n; i++){
     scanpointsx[2*i].node = i;
     scanpointsx[2*i].x = x[i*dim] - width[i*dim];
@@ -145,7 +145,7 @@ static SparseMatrix get_overlap_graph(int dim, int n, double *x, double *width,
   }
   qsort(scanpointsx, 2*n, sizeof(scan_point), comp_scan_points);
 
-  scanpointsy = N_GNEW(2*n,scan_point);
+  scan_point *scanpointsy = gv_calloc(2 * n, sizeof(scan_point));
   for (i = 0; i < n; i++){
     scanpointsy[i].node = i;
     scanpointsy[i].x = x[i*dim+1] - width[i*dim+1];