]>
Commit | Line | Data |
---|---|---|
34e8f829 A |
1 | --- heapsort_r.c.orig 2008-09-24 13:48:45.000000000 -0700 |
2 | +++ heapsort_r.c 2008-09-24 13:59:08.000000000 -0700 | |
3 | @@ -77,12 +77,12 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ | |
4 | for (par_i = initval; (child_i = par_i * 2) <= nmemb; \ | |
5 | par_i = child_i) { \ | |
6 | child = base + child_i * size; \ | |
7 | - if (child_i < nmemb && compar(child, child + size) < 0) { \ | |
8 | + if (child_i < nmemb && compar(thunk, child, child + size) < 0) { \ | |
9 | child += size; \ | |
10 | ++child_i; \ | |
11 | } \ | |
12 | par = base + par_i * size; \ | |
13 | - if (compar(child, par) <= 0) \ | |
14 | + if (compar(thunk, child, par) <= 0) \ | |
15 | break; \ | |
16 | SWAP(par, child, count, size, tmp); \ | |
17 | } \ | |
18 | @@ -108,7 +108,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ | |
19 | #define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) { \ | |
20 | for (par_i = 1; (child_i = par_i * 2) <= nmemb; par_i = child_i) { \ | |
21 | child = base + child_i * size; \ | |
22 | - if (child_i < nmemb && compar(child, child + size) < 0) { \ | |
23 | + if (child_i < nmemb && compar(thunk, child, child + size) < 0) { \ | |
24 | child += size; \ | |
25 | ++child_i; \ | |
26 | } \ | |
27 | @@ -120,7 +120,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ | |
28 | par_i = child_i / 2; \ | |
29 | child = base + child_i * size; \ | |
30 | par = base + par_i * size; \ | |
31 | - if (child_i == 1 || compar(k, par) < 0) { \ | |
32 | + if (child_i == 1 || compar(thunk, k, par) < 0) { \ | |
33 | COPY(child, k, count, size, tmp1, tmp2); \ | |
34 | break; \ | |
35 | } \ | |
36 | @@ -135,11 +135,12 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ | |
37 | * a data set that will trigger the worst case is nonexistent. Heapsort's | |
38 | * only advantage over quicksort is that it requires little additional memory. | |
39 | */ | |
40 | -int | |
41 | -heapsort(vbase, nmemb, size, compar) | |
42 | +__private_extern__ int | |
43 | +__heapsort_r(vbase, nmemb, size, thunk, compar) | |
44 | void *vbase; | |
45 | size_t nmemb, size; | |
46 | - int (*compar)(const void *, const void *); | |
47 | + void *thunk; | |
48 | + int (*compar)(void *, const void *, const void *); | |
49 | { | |
50 | size_t cnt, i, j, l; | |
51 | char tmp, *tmp1, *tmp2; |