From: Olaf Wintermann Date: Sun, 16 Jan 2022 21:09:53 +0000 (+0100) Subject: fix qsort call in util_find_next_file X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=a34cf9850d2e5213c1bdef50cbe315d9542517ef;p=uwplayer.git fix qsort call in util_find_next_file --- 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