summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-29 15:46:14 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-29 15:46:14 -0500
commit565b5e619ed64f459f1b38b5b94bb72b5b9a714f (patch)
treeb51c3c8cbac11346cafceb7c672222d74c4c7107 /util.c
parent5230cb1533d9e30e9870975cba2cd7e7e86bc22a (diff)
parent6f6ae8af3e3fdee60d38fa12f25ff83097522807 (diff)
merge
Diffstat (limited to 'util.c')
-rw-r--r--util.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/util.c b/util.c
index d805830..4a5340b 100644
--- a/util.c
+++ b/util.c
@@ -191,23 +191,16 @@ static int str_qsort_case_insensitive_cmp(const void *av, const void *bv) {
return strcmp_case_insensitive(*a, *b);
}
-static void *qsort_ctx_data;
-static int (*qsort_ctx_cmp)(const void *, const void *, void *data);
+static void *qsort_ctx_arg;
+static int (*qsort_ctx_cmp)(void *, const void *, const void *);
static int qsort_with_context_cmp(const void *a, const void *b) {
- return qsort_ctx_cmp(a, b, qsort_ctx_data);
+ return qsort_ctx_cmp(qsort_ctx_arg, 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
+static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*compar)(void *, const void *, const void *), void *arg) {
+ // @TODO(eventually): write this yourself
// just use global variables. hopefully we don't try to run this in something multithreaded!
- qsort_ctx_data = arg;
+ qsort_ctx_arg = arg;
qsort_ctx_cmp = compar;
qsort(base, nmemb, size, qsort_with_context_cmp);
-#endif
}