benilla-re systems structs docs

_qsort

function · crt · primitive

Address
0x73f727 · 340 bytes, up to 0x73f87a
Signature
void __cdecl (void *base, uint32_t num, uint32_t width, int (*compare)(const void *, const void *))
Meaning
Sorts an array in place by quicksort on a middle pivot, with a selection sort for ranges of 8 elements or fewer
Confidence
verified, proof one
Finding
ui/auctionlists#the-c-runtime-qsort
Test
ui::crt_qsort_difftest

Finding: The C runtime qsort in ui: auction lists, sorting and deposits

qsort(base, num, width, comp) (0x73f727, __cdecl) reads only the sign of comp's int. It returns at once for num below 2 or a width of 0. A range from lo to hi of 8 elements or fewer goes to the short sort. A larger one swaps the element size / 2 places above lo with lo, the pivot. loguy steps up from lo while loguy <= hi and comp(loguy, lo) <= 0; higuy steps down from hi + width while higuy > lo and comp(higuy, lo) >= 0. While higuy >= loguy they swap and the scans resume; then lo swaps with higuy. The pivot is every partition call's second argument. Equal elements are not kept in order.

The derivation is in the doc.

Callers 43

Callees 2

Calls and jumps by a bare address, from tables/calls.tsv.