summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-24 14:56:00 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-24 14:56:00 -0500
commit8c5eb397121c7fb3fa7feb2391d7c9b674b4190b (patch)
treecee9002f9e748eb4ca1861dd137abf366ac0ecba /util.c
parentb9079377328e9abeb20950ac144a7ebd98fde88e (diff)
file selector much nicer interface
Diffstat (limited to 'util.c')
-rw-r--r--util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/util.c b/util.c
index bf0f71f..a6dd3d9 100644
--- a/util.c
+++ b/util.c
@@ -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
+}