diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 10:44:46 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 10:44:46 -0500 |
commit | 6f6ae8af3e3fdee60d38fa12f25ff83097522807 (patch) | |
tree | 353936408eb0329a9833db8d847e1e4a69ae18b8 /util.c | |
parent | 31b5649b131695300f39563640c4af8f0d3032cb (diff) |
got windows build to work again
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -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 } |