mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Consolidate duplicate implementations of compare_integers
Both Inertia and Twiddle previously included static implementations of this exact same function, which was passed to `qsort()` as a comparator. With this change, a single global implementation is provided in misc.c, which will hopefully reduce code duplication going forward. I'm refactoring this in preparation for the upcoming fallback polygon fill function, which I'm about to add.
This commit is contained in:

committed by
Simon Tatham

parent
1c1899ee1c
commit
2a57df6be9
12
inertia.c
12
inertia.c
@ -722,18 +722,6 @@ static int move_goes_to(int w, int h, char *grid, int x, int y, int d)
|
||||
return (y*w+x)*DP1+dr;
|
||||
}
|
||||
|
||||
static int compare_integers(const void *av, const void *bv)
|
||||
{
|
||||
const int *a = (const int *)av;
|
||||
const int *b = (const int *)bv;
|
||||
if (*a < *b)
|
||||
return -1;
|
||||
else if (*a > *b)
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *solve_game(const game_state *state, const game_state *currstate,
|
||||
const char *aux, const char **error)
|
||||
{
|
||||
|
Reference in New Issue
Block a user