X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/5f4d86c1219d56604890d932a3152b3b5dd15b55..34e8f8296870d0e8695f90e1a54240a589d41312:/stdlib/FreeBSD/heapsort_r.c.patch diff --git a/stdlib/FreeBSD/heapsort_r.c.patch b/stdlib/FreeBSD/heapsort_r.c.patch new file mode 100644 index 0000000..04968f7 --- /dev/null +++ b/stdlib/FreeBSD/heapsort_r.c.patch @@ -0,0 +1,51 @@ +--- heapsort_r.c.orig 2008-09-24 13:48:45.000000000 -0700 ++++ heapsort_r.c 2008-09-24 13:59:08.000000000 -0700 +@@ -77,12 +77,12 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ + for (par_i = initval; (child_i = par_i * 2) <= nmemb; \ + par_i = child_i) { \ + child = base + child_i * size; \ +- if (child_i < nmemb && compar(child, child + size) < 0) { \ ++ if (child_i < nmemb && compar(thunk, child, child + size) < 0) { \ + child += size; \ + ++child_i; \ + } \ + par = base + par_i * size; \ +- if (compar(child, par) <= 0) \ ++ if (compar(thunk, child, par) <= 0) \ + break; \ + SWAP(par, child, count, size, tmp); \ + } \ +@@ -108,7 +108,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ + #define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) { \ + for (par_i = 1; (child_i = par_i * 2) <= nmemb; par_i = child_i) { \ + child = base + child_i * size; \ +- if (child_i < nmemb && compar(child, child + size) < 0) { \ ++ if (child_i < nmemb && compar(thunk, child, child + size) < 0) { \ + child += size; \ + ++child_i; \ + } \ +@@ -120,7 +120,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ + par_i = child_i / 2; \ + child = base + child_i * size; \ + par = base + par_i * size; \ +- if (child_i == 1 || compar(k, par) < 0) { \ ++ if (child_i == 1 || compar(thunk, k, par) < 0) { \ + COPY(child, k, count, size, tmp1, tmp2); \ + break; \ + } \ +@@ -135,11 +135,12 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ + * a data set that will trigger the worst case is nonexistent. Heapsort's + * only advantage over quicksort is that it requires little additional memory. + */ +-int +-heapsort(vbase, nmemb, size, compar) ++__private_extern__ int ++__heapsort_r(vbase, nmemb, size, thunk, compar) + void *vbase; + size_t nmemb, size; +- int (*compar)(const void *, const void *); ++ void *thunk; ++ int (*compar)(void *, const void *, const void *); + { + size_t cnt, i, j, l; + char tmp, *tmp1, *tmp2;