浏览代码

d.mon: Allocate less memory

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65054 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 10 年之前
父节点
当前提交
6cbb37796e
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      display/d.mon/list.c

+ 1 - 1
display/d.mon/list.c

@@ -52,7 +52,6 @@ void list_mon(char ***list, int *n)
     while ((dp = readdir(dirp)) != NULL) {
     while ((dp = readdir(dirp)) != NULL) {
 	int ret;
 	int ret;
 
 
-        *list = G_realloc(*list, (*n + 1) * sizeof(char *));
         if (!dp->d_name || dp->d_name[0] == '.')
         if (!dp->d_name || dp->d_name[0] == '.')
 	    continue;
 	    continue;
 
 
@@ -63,6 +62,7 @@ void list_mon(char ***list, int *n)
         if (ret != 0 || !S_ISDIR(s.st_mode))
         if (ret != 0 || !S_ISDIR(s.st_mode))
             continue;
             continue;
 
 
+        *list = G_realloc(*list, (*n + 1) * sizeof(char *));
         (*list)[*n] = dp->d_name;
         (*list)[*n] = dp->d_name;
         (*n)++;
         (*n)++;
     }
     }