浏览代码

minor refactoring

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36714 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 16 年之前
父节点
当前提交
2509910a25
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      general/g.mapsets/main.c

+ 3 - 3
general/g.mapsets/main.c

@@ -268,10 +268,10 @@ int main(int argc, char *argv[])
 
 static void append_mapset(char **path, const char *mapset)
 {
-    int init = (*path == NULL);
+    int len = (*path == NULL ? 0 : strlen(*path));
 
-    *path = (char *)G_realloc(*path, (init ? 0 : strlen(*path)) + strlen(mapset) + 2);
-    if (init)
+    *path = (char *)G_realloc(*path, len + strlen(mapset) + 2);
+    if (!len)
         *path[0] = '\0';
     strcat(*path, mapset);
     strcat(*path, " ");