diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-24 14:56:00 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-24 14:56:00 -0500 |
commit | 8c5eb397121c7fb3fa7feb2391d7c9b674b4190b (patch) | |
tree | cee9002f9e748eb4ca1861dd137abf366ac0ecba /util.c | |
parent | b9079377328e9abeb20950ac144a7ebd98fde88e (diff) |
file selector much nicer interface
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -191,3 +191,15 @@ static int str_qsort_case_insensitive_cmp(const void *av, const void *bv) { char const *const *a = av, *const *b = bv; return strcmp_case_insensitive(*a, *b); } + +// qsort but with a user void* +static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg) { +#if _WIN32 + qsort_s(base, nmemb, size, compar, arg); +#elif __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8) + // GNU doesn't have qsort_s ): + qsort_r(base, nmemb, size, compar, arg); +#else +#error "No qsort_r/qsort_s. You can try filling in this function if you know what you're doing." +#endif +} |