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:
Franklin Wei
2024-08-11 17:26:52 -04:00
committed by Simon Tatham
parent 1c1899ee1c
commit 2a57df6be9
5 changed files with 25 additions and 25 deletions

View File

@ -5337,6 +5337,16 @@ equivalent to a bitwise-AND with \cw{~MOD_MASK}.
Swap two regions of memory of \cw{size} bytes. The two regions must
not overlap.
\S{utils-compare-integers} \cw{compare_integers()}
\c int compare_integers(const void *av, const void *bv);
Compare the ints pointed to by \c{av} and \c{bv}. It returns an
integer less than, equal to, or greater than zero if the first
argument is respectively less than, equal to, or greater than the
second. This function is intended to be passed to \c{qsort()} for
sorting ints in ascending order.
\C{writing} How to write a new puzzle
This chapter gives a guide to how to actually write a new puzzle: