projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
798a12e
)
don't compare elements with themselves during qsort.
author
Rich Felker
<dalias@aerifal.cx>
Thu, 17 Feb 2011 05:03:24 +0000
(
00:03
-0500)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 17 Feb 2011 05:03:24 +0000
(
00:03
-0500)
this is actually a workaround for a bug in gcc, whereby it asserts
inequality of the keys being compared...
src/stdlib/qsort.c
patch
|
blob
|
history
diff --git
a/src/stdlib/qsort.c
b/src/stdlib/qsort.c
index f5bf3d024fc3b2ff93d7f3c0e8998b6691ce03a2..91a3361d7c55881bb8bae66e0dfa3134d161950e 100644
(file)
--- a/
src/stdlib/qsort.c
+++ b/
src/stdlib/qsort.c
@@
-28,7
+28,7
@@
static void sift(char *base, size_t root, size_t nel, size_t width, int (*cmp)(c
max = 2*root;
if (max < nel && cmp(base+max*width, base+(max+1)*width) < 0)
max++;
- if (cmp(base+root*width, base+max*width) < 0) {
+ if (
max &&
cmp(base+root*width, base+max*width) < 0) {
swap(base+root*width, base+max*width, width);
root = max;
} else break;