platform/win32.c
changeset 362 ac8c846a0a66
parent 338 4f6d300bf1d7
child 427 c38ace41039f
--- a/platform/win32.c	Mon Jul 22 12:08:56 2002 +0000
+++ b/platform/win32.c	Tue Jul 23 07:46:36 2002 +0000
@@ -424,9 +424,7 @@
 LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
                                                   int omitSymLinks)
 {
-    LinkedStringList *retval = NULL;
-    LinkedStringList *l = NULL;
-    LinkedStringList *prev = NULL;
+    LinkedStringList *retval = NULL, *p = NULL;
     HANDLE dir;
     WIN32_FIND_DATA ent;
     char *SearchPath;
@@ -460,26 +458,7 @@
         if (strcmp(ent.cFileName, "..") == 0)
             continue;
 
-        l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
-        if (l == NULL)
-            break;
-
-        l->str = (char *) malloc(strlen(ent.cFileName) + 1);
-        if (l->str == NULL)
-        {
-            free(l);
-            break;
-        } /* if */
-
-        strcpy(l->str, ent.cFileName);
-
-        if (retval == NULL)
-            retval = l;
-        else
-            prev->next = l;
-
-        prev = l;
-        l->next = NULL;
+        retval = __PHYSFS_addToLinkedStringList(retval, &p, ent.cFileName, -1);
     } while (FindNextFile(dir, &ent) != 0);
 
     FindClose(dir);