From a34cf9850d2e5213c1bdef50cbe315d9542517ef Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sun, 16 Jan 2022 22:09:53 +0100 Subject: [PATCH] fix qsort call in util_find_next_file --- application/utils.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/application/utils.c b/application/utils.c index 7d123e3..fd615fd 100644 --- a/application/utils.c +++ b/application/utils.c @@ -91,6 +91,13 @@ char* util_parent_path(const char *path) { typedef int (*cmpfnc)(const void *, const void *); +int fcmp(const void *d1, const void *d2) { + const char **f1 = (const char **)d1; + const char **f2 = (const char **)d2; + int r = strcmp(*f1, *f2); + return r; +} + char* util_find_next_file(char *current_file) { char *current_folder = util_parent_path(current_file); char *current_file_name = util_resource_name(current_file); @@ -143,9 +150,10 @@ char* util_find_next_file(char *current_file) { char *result = NULL; if(!abort) { - qsort(files, nfiles, sizeof(char*), (cmpfnc)strcmp); + qsort(files, nfiles, sizeof(char*), fcmp); // search array for current file and return the successor for(int i=0;i