]> granicus.if.org Git - graphviz/commitdiff
delaunay_tri/mkSurface: fix mismatch of calling convention in 'addEdge'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 19:55:50 +0000 (11:55 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 10 Nov 2021 02:34:09 +0000 (18:34 -0800)
The compiler said about this code:

  delaunay.c:355:31: warning: cast between incompatible function types from
    ‘void (*)(GtsSegment *, estate *)’ {aka ‘void (*)(struct _GtsSegment *,
    struct <anonymous> *)’} to ‘gint (*)(void *, void *)’ {aka
    ‘int (*)(void *, void *)’} [-Wcast-function-type]
    gts_surface_foreach_edge (s, (GtsFunc) addEdge, &state);
                                 ^

Similar to the prior commit, this was relying on a coincident return value of 0
from the callback function.

lib/neatogen/delaunay.c

index ac578ab6da9f0d776d37f7980a9b8f3d4b1f0487..f68819e03502f00cda0462d0d36d932729b9ef39 100644 (file)
@@ -302,14 +302,18 @@ typedef struct {
     int* edges;
 } estate;
 
-static void addEdge (GtsSegment * e, estate* es)
-{
+static gint addEdge(void *edge, void *state) {
+    GtsSegment *e = edge;
+    estate *es = state;
+
     int source = ((GVertex*)(e->v1))->idx;
     int dest = ((GVertex*)(e->v2))->idx;
 
     es->edges[2*(es->n)] = source;
     es->edges[2*(es->n)+1] = dest;
     es->n += 1;
+
+    return 0;
 }
 
 // when moving to C11, qsort_s should be used instead of having a global
@@ -359,7 +363,7 @@ int *delaunay_tri(double *x, double *y, int n, int* pnedges)
        edges = N_GNEW(2 * nedges, int);
        state.n = 0;
        state.edges = edges;
-       gts_surface_foreach_edge (s, (GtsFunc) addEdge, &state);
+       gts_surface_foreach_edge(s, addEdge, &state);
     }
     else {
        int* vs = N_GNEW(n, int);
@@ -483,7 +487,7 @@ mkSurface (double *x, double *y, int n, int* segs, int nsegs)
 
     state.n = 0;
     state.edges = segs;
-    gts_surface_foreach_edge (s, (GtsFunc) addEdge, &state);
+    gts_surface_foreach_edge(s, addEdge, &state);
 
     gts_surface_foreach_face (s, (GtsFunc) cntFace, &nfaces);