]> granicus.if.org Git - graphviz/commitdiff
tclpathplan gt: rephrase to avoid having to cast pointers to this function
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Sep 2021 22:25:39 +0000 (15:25 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Sep 2021 17:22:21 +0000 (10:22 -0700)
Similar to commit fe231a8f6beae5dd8ac8cd8b9338cc815881a714.

tclpkg/tclpathplan/find_ints.c

index 9ae3db5cd8ba6439f922692f73b5fb6e38f0ed0b..d8155e498c420a9d65c7a0d6d96f9202c7e78df4 100644 (file)
@@ -14,7 +14,7 @@
 
 void find_intersection(struct vertex *l, struct vertex *m,
                       struct intersection ilist[], struct data *input);
-static int gt(struct vertex **i, struct vertex **j);
+static int gt(const void *a, const void *b);
 
 void find_ints(struct vertex vertex_list[],
        struct polygon polygon_list[],
@@ -36,8 +36,7 @@ void find_ints(struct vertex vertex_list[],
        pvertex[i] = vertex_list + i;
 
 /* sort vertices by x coordinate       */
-    qsort(pvertex, input->nvertices, sizeof(struct vertex *),
-         (int (*)(const void *, const void *))gt);
+    qsort(pvertex, input->nvertices, sizeof(struct vertex *), gt);
 
 /* walk through the vertices in order of increasing x coordinate       */
     for (i = 0; i < input->nvertices; i++) {
@@ -103,8 +102,10 @@ void find_ints(struct vertex vertex_list[],
     free(pvertex);
 }
 
-static int gt(struct vertex **i, struct vertex **j)
+static int gt(const void *a, const void *b)
 {                              /* i > j if i.x > j.x or i.x = j.x and i.y > j.y  */
+    const struct vertex *const *i = a;
+    const struct vertex *const *j = b;
     double t;
     if ((t = (*i)->pos.x - (*j)->pos.x) != 0.)
        return ((t > 0.) ? 1 : -1);