From 89c438e149a91fffa74b2669f7e0cd05abc3420f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 20 Apr 2023 14:06:43 +0100 Subject: 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. --- puzzles.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'puzzles.h') 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 -- cgit v1.1