]> uap-core.de Git - uwplayer.git/commitdiff
fix qsort call in util_find_next_file
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 16 Jan 2022 21:09:53 +0000 (22:09 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 16 Jan 2022 21:09:53 +0000 (22:09 +0100)
application/utils.c

index 7d123e36b78feda62c462b13cefc12d96ec5edf2..fd615fd0b8a30cecde5c8072385c623f05a6ef50 100644 (file)
@@ -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<nfiles;i++) {
+            char *c = files[i];
             if(!strcmp(files[i], current_file_name)) {
                 if(i + 1 < nfiles) {
                     result = util_concat_path(current_folder, files[i+1]);