]> granicus.if.org Git - graphviz/commitdiff
nearest_neighbor_graph: cast the result of calls to 'malloc'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 8 Jan 2022 18:47:32 +0000 (10:47 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 11 Jan 2022 15:51:48 +0000 (07:51 -0800)
This pre-emptively suppresses some `-fpermissive` warnings when transitioning
this code to C++ in an upcoming commit.

Gitlab: #2154

lib/mingle/nearest_neighbor_graph.c

index 1de680376dc0f3c82ef1e0bfd91520ad6738eb25..b74e3dbdfe5773dfd6ca7fd1e25b3e39212cc2d1 100644 (file)
@@ -32,9 +32,9 @@ SparseMatrix nearest_neighbor_graph(int nPts, int num_neigbors, double *x, doubl
   int k = num_neigbors;
 
   /* need to *2 as we do two sweeps of neighbors, so could have repeats */
-  irn =  MALLOC(sizeof(int)*nPts*k*2);
-  jcn =  MALLOC(sizeof(int)*nPts*k*2);
-  val =  MALLOC(sizeof(double)*nPts*k*2);
+  irn =  (int*)MALLOC(sizeof(int)*nPts*k*2);
+  jcn =  (int*)MALLOC(sizeof(int)*nPts*k*2);
+  val =  (double*)MALLOC(sizeof(double)*nPts*k*2);
 
 #ifdef HAVE_ANN
   nearest_neighbor_graph_ann(nPts, num_neigbors, eps, x, &nz, &irn, &jcn, &val);