summaryrefslogtreecommitdiffstats
path: root/lib/util/stable_sort.h
blob: 17329b81ac7909b479240877dc4c27ab7f0e360c (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
#ifndef HAVE_STABLE_SORT_H
#define HAVE_STABLE_SORT_H 1

#ifdef __COMPAR_FN_T
typedef __compar_fn_t samba_compare_fn_t;

#ifdef __USE_GNU
/* glibc defines __compar_d_fn_t for qsort_r */
typedef __compar_d_fn_t samba_compare_with_context_fn_t;
#endif

#else
typedef int (*samba_compare_fn_t) (const void *, const void *);
typedef int (*samba_compare_with_context_fn_t) (const void *, const void *, void *);
#endif



bool stable_sort_r(void *array, void *aux,
		   size_t n,
		   size_t s,
		   samba_compare_with_context_fn_t cmpfn,
		   void *opaque);

bool stable_sort(void *array, void *aux,
		 size_t n,
		 size_t s,
		 samba_compare_fn_t cmpfn);


bool stable_sort_talloc_r(TALLOC_CTX *mem_ctx,
			  void *array,
			  size_t n,
			  size_t s,
			  samba_compare_with_context_fn_t cmpfn,
			  void *opaque);


bool stable_sort_talloc(TALLOC_CTX *mem_ctx,
			void *array,
			size_t n,
			size_t s,
			samba_compare_fn_t cmpfn);


#endif /* HAVE_STABLE_SORT_H */