chiark / gitweb /
Adopt C99 bool in the findloop API.
authorSimon Tatham <anakin@pobox.com>
Tue, 13 Nov 2018 21:40:23 +0000 (21:40 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 13 Nov 2018 21:48:24 +0000 (21:48 +0000)
This shouldn't be a disruptive change at all: findloop_run and
findloop_is_loop_edge now return bool in place of int, but client code
should automatically adjust without needing any changes.

findloop.c
puzzles.h

index e6b2654cadf6d867f4705c006db214cb310224ce..30c128cf58335adefb81f5ea5a7599d67713bbfd 100644 (file)
@@ -37,7 +37,7 @@ void findloop_free_state(struct findloopstate *state)
     sfree(state);
 }
 
-int findloop_is_loop_edge(struct findloopstate *pv, int u, int v)
+bool findloop_is_loop_edge(struct findloopstate *pv, int u, int v)
 {
     /*
      * Since the algorithm is intended for finding bridges, and a
@@ -56,8 +56,8 @@ int findloop_is_loop_edge(struct findloopstate *pv, int u, int v)
     return !(pv[u].bridge == v || pv[v].bridge == u);
 }
 
-int findloop_run(struct findloopstate *pv, int nvertices,
-                 neighbour_fn_t neighbour, void *ctx)
+bool findloop_run(struct findloopstate *pv, int nvertices,
+                  neighbour_fn_t neighbour, void *ctx)
 {
     int u, v, w, root, index;
     int nbridges, nedges;
index d6d9e513795581c432305a8be665c9cedecec2de..887af7b19e09004bab41b2fcfc46ac3ed5b681c8 100644 (file)
--- a/puzzles.h
+++ b/puzzles.h
@@ -580,22 +580,22 @@ void findloop_free_state(struct findloopstate *);
 typedef int (*neighbour_fn_t)(int vertex, void *ctx);
 /*
  * Actual function to find loops. 'ctx' will be passed unchanged to
- * the 'neighbour' function to query graph edges. Returns FALSE if no
- * loop was found, or TRUE if one was.
+ * the 'neighbour' function to query graph edges. Returns false if no
+ * loop was found, or true if one was.
  */
-int findloop_run(struct findloopstate *state, int nvertices,
-                 neighbour_fn_t neighbour, void *ctx);
+bool findloop_run(struct findloopstate *state, int nvertices,
+                  neighbour_fn_t neighbour, void *ctx);
 /*
  * Query whether an edge is part of a loop, in the output of
  * find_loops.
  *
  * Due to the internal storage format, if you pass u,v which are not
- * connected at all, the output will be TRUE. (The algorithm actually
+ * connected at all, the output will be true. (The algorithm actually
  * stores an exhaustive list of *non*-loop edges, because there are
  * fewer of those, so really it's querying whether the edge is on that
  * list.)
  */
-int findloop_is_loop_edge(struct findloopstate *state, int u, int v);
+bool findloop_is_loop_edge(struct findloopstate *state, int u, int v);
 
 /*
  * Data structure containing the function calls and data specific