summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
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
+}