mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -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
11
misc.c
11
misc.c
@ -351,6 +351,17 @@ void draw_rect_corners(drawing *dr, int cx, int cy, int r, int col)
|
||||
draw_line(dr, cx + r, cy + r, cx + r/2, cy + r, col);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
char *move_cursor(int button, int *x, int *y, int maxw, int maxh, bool wrap,
|
||||
bool *visible)
|
||||
{
|
||||
|
Reference in New Issue
Block a user