ball/demo: alloc new array slot only when needed
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 17 Apr 2009 10:54:06 +0000 (10:54 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 17 Apr 2009 10:54:06 +0000 (10:54 +0000)
(A slight tweak to r2821.)

git-svn-id: https://s.snth.net/svn/neverball/trunk@2824 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/demo.c

index 7862e78..46046f5 100644 (file)
@@ -172,10 +172,12 @@ static void demo_init(void)
 static void demo_scan_file(const char *filename)
 {
     FILE *fp;
-    struct demo *d = array_add(demos);
+    struct demo *d;
 
     if ((fp = fopen(config_user(filename), FMODE_RB)))
     {
+        d = array_add(demos);
+
         if (demo_header_read(fp, d))
         {
             strncpy(d->filename, config_user(filename), MAXSTR);
@@ -186,7 +188,6 @@ static void demo_scan_file(const char *filename)
 
         fclose(fp);
     }
-    else array_del(demos);
 }
 
 #ifdef _WIN32