changeset 34580:065029b847e5

Move buffer at top of function and rename it. Additionally, use sizeof() instead of numeric constant for its size.
author ib
date Thu, 09 Feb 2012 14:14:39 +0000
parents 5097d56b31b1
children dba158d9b986
files gui/cfg.c
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Thu Feb 09 13:57:25 2012 +0000
+++ b/gui/cfg.c	Thu Feb 09 14:14:39 2012 +0000
@@ -240,7 +240,7 @@
 
 void cfg_read(void)
 {
-    char *fname;
+    char *fname, line[512];
     FILE *file;
 
     player_idle_mode = 1;   // GUI is in idle mode by default
@@ -274,16 +274,15 @@
 
     if (file) {
         while (!feof(file)) {
-            char tmp[512];
             plItem *item;
 
-            if (fgetstr(tmp, 512, file) == NULL)
+            if (fgetstr(line, sizeof(line), file) == NULL)
                 continue;
 
             item       = calloc(1, sizeof(plItem));
-            item->path = strdup(tmp);
-            fgetstr(tmp, 512, file);
-            item->name = strdup(tmp);
+            item->path = strdup(line);
+            fgetstr(line, sizeof(line), file);
+            item->name = strdup(line);
             listSet(gtkAddPlItem, item);
         }
 
@@ -299,14 +298,13 @@
 
     if (file) {
         while (!feof(file)) {
-            char tmp[512];
             urlItem *item;
 
-            if (fgetstr(tmp, 512, file) == NULL)
+            if (fgetstr(line, sizeof(line), file) == NULL)
                 continue;
 
             item      = calloc(1, sizeof(urlItem));
-            item->url = strdup(tmp);
+            item->url = strdup(line);
             listSet(gtkAddURLItem, item);
         }
 
@@ -324,12 +322,10 @@
         int i = 0;
 
         while (!feof(file)) {
-            char tmp[512];
-
-            if (fgetstr(tmp, 512, file) == NULL)
+            if (fgetstr(line, sizeof(line), file) == NULL)
                 continue;
 
-            fsHistory[i++] = gstrdup(tmp);
+            fsHistory[i++] = gstrdup(line);
         }
 
         fclose(file);