1 | /* |
---|
2 | FUNCTION |
---|
3 | <<qsort_r>>---sort an array |
---|
4 | |
---|
5 | INDEX |
---|
6 | qsort_r |
---|
7 | |
---|
8 | SYNOPSIS |
---|
9 | #define _BSD_SOURCE |
---|
10 | #include <stdlib.h> |
---|
11 | void qsort_r(void *<[base]>, size_t <[nmemb]>, size_t <[size]>, |
---|
12 | void *<[thunk]>, |
---|
13 | int (*<[compar]>)(void*, const void *, const void *)); |
---|
14 | |
---|
15 | #define _GNU_SOURCE |
---|
16 | #include <stdlib.h> |
---|
17 | void qsort_r(void *<[base]>, size_t <[nmemb]>, size_t <[size]>, |
---|
18 | int (*<[compar]>)(const void *, const void *, void *), |
---|
19 | void *<[thunk]>); |
---|
20 | |
---|
21 | DESCRIPTION |
---|
22 | <<qsort_r>> sorts an array (beginning at <[base]>) of <[nmemb]> objects. |
---|
23 | <[size]> describes the size of each element of the array. |
---|
24 | |
---|
25 | You must supply a pointer to a comparison function, using the argument |
---|
26 | shown as <[compar]>. (This permits sorting objects of unknown |
---|
27 | properties.) There are two forms of this function, in each the |
---|
28 | comparison function is defined to accept three arguments, but in a |
---|
29 | different order. Two are pointers to an element of the array starting at |
---|
30 | <[base]>, and another being an arbitrary pointer <[thunk]>. The |
---|
31 | result of <<(*<[compar]>)>> must be negative if the first argument is |
---|
32 | less than the second, zero if the two arguments match, and positive if |
---|
33 | the first argument is greater than the second (where ``less than'' and |
---|
34 | ``greater than'' refer to whatever arbitrary ordering is appropriate). |
---|
35 | |
---|
36 | The array is sorted in place; that is, when <<qsort_r>> returns, the |
---|
37 | array elements beginning at <[base]> have been reordered. |
---|
38 | |
---|
39 | RETURNS |
---|
40 | <<qsort_r>> does not return a result. |
---|
41 | |
---|
42 | PORTABILITY |
---|
43 | <<qsort_r>>, in various forms, appears in both BSD and glibc. |
---|
44 | */ |
---|
45 | |
---|
46 | #define _GNU_SOURCE |
---|
47 | #define I_AM_GNU_QSORT_R |
---|
48 | #include "qsort.c" |
---|