aboutsummaryrefslogtreecommitdiff
path: root/puzzles.h
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-20 14:06:43 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-20 17:23:21 +0100
commit89c438e149a91fffa74b2669f7e0cd05abc3420f (patch)
treea307d0c2dde7c2868e32a840497d44051d9b4630 /puzzles.h
parent7abf85a9c6b460698994d9cfa538b7b26fed5e87 (diff)
downloadpuzzles-89c438e149a91fffa74b2669f7e0cd05abc3420f.zip
puzzles-89c438e149a91fffa74b2669f7e0cd05abc3420f.tar.gz
puzzles-89c438e149a91fffa74b2669f7e0cd05abc3420f.tar.bz2
puzzles-89c438e149a91fffa74b2669f7e0cd05abc3420f.tar.xz
Declare all dsfs as a dedicated type name 'DSF'.
In this commit, 'DSF' is simply a typedef for 'int', so that the new declaration form 'DSF *' translates to the same type 'int *' that dsfs have always had. So all we're doing here is mechanically changing type declarations throughout the code.
Diffstat (limited to 'puzzles.h')
-rw-r--r--puzzles.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/puzzles.h b/puzzles.h
index e2d2112..86e9316 100644
--- a/puzzles.h
+++ b/puzzles.h
@@ -426,28 +426,29 @@ char *button2label(int button);
/*
* dsf.c
*/
-int *snew_dsf(int size);
-void dsf_free(int *dsf);
+typedef int DSF;
+DSF *snew_dsf(int size);
+void dsf_free(DSF *dsf);
-void print_dsf(int *dsf, int size);
+void print_dsf(DSF *dsf, int size);
-void dsf_copy(int *to, int *from, int size);
+void dsf_copy(DSF *to, DSF *from, int size);
/* Return the canonical element of the equivalence class containing element
* val. If 'inverse' is non-NULL, this function will put into it a flag
* indicating whether the canonical element is inverse to val. */
-int edsf_canonify(int *dsf, int val, bool *inverse);
-int dsf_canonify(int *dsf, int val);
-int dsf_size(int *dsf, int val);
+int edsf_canonify(DSF *dsf, int val, bool *inverse);
+int dsf_canonify(DSF *dsf, int val);
+int dsf_size(DSF *dsf, int val);
/* Allow the caller to specify that two elements should be in the same
* equivalence class. If 'inverse' is true, the elements are actually opposite
* to one another in some sense. This function will fail an assertion if the
* caller gives it self-contradictory data, ie if two elements are claimed to
* be both opposite and non-opposite. */
-void edsf_merge(int *dsf, int v1, int v2, bool inverse);
-void dsf_merge(int *dsf, int v1, int v2);
-void dsf_init(int *dsf, int len);
+void edsf_merge(DSF *dsf, int v1, int v2, bool inverse);
+void dsf_merge(DSF *dsf, int v1, int v2);
+void dsf_init(DSF *dsf, int len);
/*
* tdq.c
@@ -565,9 +566,9 @@ void free_combi(combi_ctx *combi);
* divvy.c
*/
/* divides w*h rectangle into pieces of size k. Returns w*h dsf. */
-int *divvy_rectangle(int w, int h, int k, random_state *rs);
+DSF *divvy_rectangle(int w, int h, int k, random_state *rs);
/* Same, but only tries once, and may fail. (Exposed for test program.) */
-int *divvy_rectangle_attempt(int w, int h, int k, random_state *rs);
+DSF *divvy_rectangle_attempt(int w, int h, int k, random_state *rs);
/*
* findloop.c