]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdlib: Handle various corner cases in the fallback heapsort for qsort
authorFlorian Weimer <fweimer@redhat.com>
Tue, 21 Nov 2023 15:45:35 +0000 (16:45 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 21 Nov 2023 15:46:02 +0000 (16:46 +0100)
commit55364e1f7dfab372f0710513c4d1c967c4965f71
tree3cbcd4bb82bc1ab8db4de3c0a07c1466635b9fe7
parente4d8117b82065dc72e8df80097360e7c05a349b9
stdlib: Handle various corner cases in the fallback heapsort for qsort

The previous implementation did not consistently apply the rule that
the child nodes of node K are at 2 * K + 1 and 2 * K + 2, or
that the parent node is at (K - 1) / 2.

Add an internal test that targets the heapsort implementation
directly.

Reported-by: Stepan Golosunov <stepan@golosunov.pp.ru>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
stdlib/Makefile
stdlib/qsort.c
stdlib/tst-qsort4.c [new file with mode: 0644]