4 * This is actually combsort. It's an O(n log n) algorithm with
5 * simplicity/small code size being its main virtue.
11 static inline size_t newgap(size_t gap
)
14 if ( gap
== 9 || gap
== 10 )
22 void qsort(void *base
, size_t nmemb
, size_t size
, int (*compar
)(const void *, const void *))
33 for ( i
= 0, p1
= base
; i
< nmemb
-gap
; i
++, p1
+= size
) {
35 if ( compar(p1
, p2
= (char *)base
+j
*size
) > 0 ) {
36 memswap(p1
, p2
, size
);
40 } while ( gap
> 1 || swapped
);