stdlib: Fix heapsort for cases with exactly two elements
commit74d2731a5fb2676b64092bc25e7f193db1b17b2b
authorKuan-Wei Chiu <visitorckw@gmail.com>
Tue, 16 Jan 2024 02:16:56 +0000 (16 10:16 +0800)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 16 Jan 2024 14:00:51 +0000 (16 11:00 -0300)
tree228624cbc2f6b113d815de83ea0c5a9cbc883364
parent9d2703c109791d1ff0bf1f611b0b78f1703f51eb
stdlib: Fix heapsort for cases with exactly two elements

When malloc fails to allocate a buffer and falls back to heapsort, the
current heapsort implementation does not perform sorting when there are
exactly two elements. Heapsort is now skipped only when there is
exactly one element.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
stdlib/qsort.c