]> git.ozlabs.org Git - ccan/blob - ccan/asort/asort.c
typesafe_cb: fix fallout from API changes.
[ccan] / ccan / asort / asort.c
1 #include <ccan/asort/asort.h>
2 #include <stdlib.h>
3
4 void _asort(void *base, size_t nmemb, size_t size,
5             int(*compar)(const void *, const void *, const void *ctx),
6             const void *ctx)
7 {
8 #if HAVE_NESTED_FUNCTIONS
9         /* This gives bogus "warning: no previous prototype for ‘cmp’"
10          * with gcc 4 with -Wmissing-prototypes.  Hence the auto crap. */
11         auto int cmp(const void *a, const void *b);
12         int cmp(const void *a, const void *b)
13         {
14                 return compar(a, b, ctx);
15         }
16         qsort(base, nmemb, size, cmp);
17 #else
18         #error "Need to open-code quicksort?"
19         /* qsort is a classic "needed more real-life testing" API. */
20 #endif
21 }