Browse Source

diglib: reduce calls to G_realloc()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71785 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 years ago
parent
commit
ce6bd449c1
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lib/vector/diglib/struct_alloc.c

+ 4 - 1
lib/vector/diglib/struct_alloc.c

@@ -73,7 +73,10 @@ int dig_node_alloc_line(struct P_node * node, int add)
 
     G_debug(5, "dig_node_alloc_line(): add = %d", add);
 
-    num = node->n_lines + add;
+    if (node->n_lines + add <= node->alloc_lines)
+	return 0;
+
+    num = node->alloc_lines + add;
 
     p = G_realloc(node->lines, num * sizeof(plus_t));
     if (p == NULL)