Welcome to mirror list, hosted at ThFree Co, Russian Federation.

qsort_r.c « search « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4b6fb7e25ce779aced676d6669a2649d5643d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
FUNCTION
<<qsort_r>>---sort an array

INDEX
	qsort_r

SYNOPSIS
	#define _BSD_SOURCE
	#include <stdlib.h>
	void qsort_r(void *<[base]>, size_t <[nmemb]>, size_t <[size]>,
		     void *<[thunk]>,
		     int (*<[compar]>)(void*, const void *, const void *));

	#define _GNU_SOURCE
	#include <stdlib.h>
	void qsort_r(void *<[base]>, size_t <[nmemb]>, size_t <[size]>,
		     int (*<[compar]>)(const void *, const void *, void *),
		     void *<[thunk]>);

DESCRIPTION
<<qsort_r>> sorts an array (beginning at <[base]>) of <[nmemb]> objects.
<[size]> describes the size of each element of the array.

You must supply a pointer to a comparison function, using the argument
shown as <[compar]>.  (This permits sorting objects of unknown
properties.)  There are two forms of this function, in each the
comparison function is defined to accept three arguments, but in a
different order.  Two are pointers to an element of the array starting at
<[base]>, and another being an arbitrary pointer <[thunk]>.  The
result of <<(*<[compar]>)>> must be negative if the first argument is
less than the second, zero if the two arguments match, and positive if
the first argument is greater than the second (where ``less than'' and
``greater than'' refer to whatever arbitrary ordering is appropriate).

The array is sorted in place; that is, when <<qsort_r>> returns, the
array elements beginning at <[base]> have been reordered.

RETURNS
<<qsort_r>> does not return a result.

PORTABILITY
<<qsort_r>>, in various forms, appears in both BSD and glibc.
*/

#define _GNU_SOURCE
#define I_AM_GNU_QSORT_R
#include "qsort.c"