[GRASS-SVN] r36853 - grass/branches/releasebranch_6_4/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 21 15:09:23 EDT 2009


Author: mmetz
Date: 2009-04-21 15:09:23 -0400 (Tue, 21 Apr 2009)
New Revision: 36853

Modified:
   grass/branches/releasebranch_6_4/lib/vector/diglib/allocation.c
   grass/branches/releasebranch_6_4/lib/vector/diglib/cindex.c
   grass/branches/releasebranch_6_4/lib/vector/diglib/list.c
   grass/branches/releasebranch_6_4/lib/vector/diglib/plus.c
   grass/branches/releasebranch_6_4/lib/vector/diglib/struct_alloc.c
Log:
G_* versions for memory management

Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/allocation.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/allocation.c	2009-04-21 18:57:16 UTC (rev 36852)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/allocation.c	2009-04-21 19:09:23 UTC (rev 36853)
@@ -78,7 +78,7 @@
 
     /*  first time called allocate initial storage  */
     if (*n_elements == 0)
-	ptr = calloc((unsigned)to_alloc, (unsigned)element_size);
+	ptr = G_calloc((unsigned)to_alloc, (unsigned)element_size);
     else
 	ptr = dig__frealloc((char *)ptr, to_alloc, element_size, *n_elements);
 
@@ -126,7 +126,7 @@
 	nelem = 1;
     }
 
-    ptr = calloc((unsigned)nelem, (unsigned)elsize);
+    ptr = G_calloc((unsigned)nelem, (unsigned)elsize);
     return (ptr);
 }
 
@@ -141,7 +141,7 @@
 	nelem = 1;
     }
 
-    ptr = calloc((unsigned)nelem, (unsigned)elsize);
+    ptr = G_calloc((unsigned)nelem, (unsigned)elsize);
 
     /*  out of memory  */
     if (!ptr)
@@ -159,6 +159,6 @@
 	    *a++ = *b++;
     }
 
-    free(oldptr);
+    G_free(oldptr);
     return (ptr);
 }

Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/cindex.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/cindex.c	2009-04-21 18:57:16 UTC (rev 36852)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/cindex.c	2009-04-21 19:09:23 UTC (rev 36853)
@@ -49,7 +49,7 @@
     G_debug(2, "dig_cidx_free()");
     for (i = 0; i < Plus->n_cidx; i++) {
 	ci = &(Plus->cidx[0]);
-	free(ci->cat);
+	G_free(ci->cat);
 	ci->cat = NULL;
 	ci->field = ci->n_cats = ci->a_cats = ci->n_types = 0;
     }

Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/list.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/list.c	2009-04-21 18:57:16 UTC (rev 36852)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/list.c	2009-04-21 19:09:23 UTC (rev 36853)
@@ -37,7 +37,7 @@
 
     if (list->n_values == list->alloc_values) {
 	size = (list->n_values + 1000) * sizeof(int);
-	p = realloc((void *)list->value, size);
+	p = G_realloc((void *)list->value, size);
 	if (p == NULL)
 	    return 0;
 	list->value = (int *)p;

Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/plus.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/plus.c	2009-04-21 18:57:16 UTC (rev 36852)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/plus.c	2009-04-21 19:09:23 UTC (rev 36853)
@@ -117,12 +117,12 @@
 		continue;
 
 	    if (Node->alloc_lines > 0) {
-		free(Node->lines);
-		free(Node->angles);
+		G_free(Node->lines);
+		G_free(Node->angles);
 	    }
-	    free(Node);
+	    G_free(Node);
 	}
-	free(Plus->Node);
+	G_free(Plus->Node);
     }
     Plus->Node = NULL;
     Plus->n_nodes = 0;
@@ -148,9 +148,9 @@
 	    if (Line == NULL)
 		continue;
 
-	    free(Line);
+	    G_free(Line);
 	}
-	free(Plus->Line);
+	G_free(Plus->Line);
     }
 
     Plus->Line = NULL;
@@ -185,14 +185,14 @@
 		continue;
 
 	    if (Area->alloc_lines > 0)
-		free(Area->lines);
+		G_free(Area->lines);
 
 	    if (Area->alloc_isles > 0)
-		free(Area->isles);
+		G_free(Area->isles);
 
-	    free(Area);
+	    G_free(Area);
 	}
-	free(Plus->Area);
+	G_free(Plus->Area);
     }
     Plus->Area = NULL;
     Plus->n_areas = 0;
@@ -219,11 +219,11 @@
 		continue;
 
 	    if (Isle->alloc_lines > 0)
-		free(Isle->lines);
+		G_free(Isle->lines);
 
-	    free(Isle);
+	    G_free(Isle);
 	}
-	free(Plus->Isle);
+	G_free(Plus->Isle);
     }
 
     Plus->Isle = NULL;

Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/struct_alloc.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/struct_alloc.c	2009-04-21 18:57:16 UTC (rev 36852)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/struct_alloc.c	2009-04-21 19:09:23 UTC (rev 36853)
@@ -41,7 +41,7 @@
 {
     P_NODE *Node;
 
-    Node = (P_NODE *) malloc(sizeof(P_NODE));
+    Node = (P_NODE *) G_malloc(sizeof(P_NODE));
     if (Node == NULL)
 	return NULL;
 
@@ -69,12 +69,12 @@
 
     num = node->n_lines + add;
 
-    p = realloc(node->lines, num * sizeof(plus_t));
+    p = G_realloc(node->lines, num * sizeof(plus_t));
     if (p == NULL)
 	return -1;
     node->lines = (plus_t *) p;
 
-    p = realloc(node->angles, num * sizeof(float));
+    p = G_realloc(node->angles, num * sizeof(float));
     if (p == NULL)
 	return -1;
     node->angles = (float *)p;
@@ -96,7 +96,7 @@
     char *p;
 
     size = Plus->alloc_nodes + 1 + add;
-    p = realloc(Plus->Node, size * sizeof(P_NODE *));
+    p = G_realloc(Plus->Node, size * sizeof(P_NODE *));
     if (p == NULL)
 	return -1;
 
@@ -111,7 +111,7 @@
 {
     P_LINE *Line;
 
-    Line = (P_LINE *) malloc(sizeof(P_LINE));
+    Line = (P_LINE *) G_malloc(sizeof(P_LINE));
     if (Line == NULL)
 	return NULL;
 
@@ -130,7 +130,7 @@
     char *p;
 
     size = Plus->alloc_lines + 1 + add;
-    p = realloc(Plus->Line, size * sizeof(P_LINE *));
+    p = G_realloc(Plus->Line, size * sizeof(P_LINE *));
     if (p == NULL)
 	return -1;
 
@@ -152,7 +152,7 @@
     char *p;
 
     size = Plus->alloc_areas + 1 + add;
-    p = realloc(Plus->Area, size * sizeof(P_AREA *));
+    p = G_realloc(Plus->Area, size * sizeof(P_AREA *));
     if (p == NULL)
 	return -1;
 
@@ -175,7 +175,7 @@
 
     G_debug(3, "dig_alloc_isle():");
     size = Plus->alloc_isles + 1 + add;
-    p = realloc(Plus->Isle, size * sizeof(P_ISLE *));
+    p = G_realloc(Plus->Isle, size * sizeof(P_ISLE *));
     if (p == NULL)
 	return -1;
 
@@ -190,7 +190,7 @@
 {
     P_AREA *Area;
 
-    Area = (P_AREA *) malloc(sizeof(P_AREA));
+    Area = (P_AREA *) G_malloc(sizeof(P_AREA));
     if (Area == NULL)
 	return NULL;
 
@@ -212,7 +212,7 @@
 {
     P_ISLE *Isle;
 
-    Isle = (P_ISLE *) malloc(sizeof(P_ISLE));
+    Isle = (P_ISLE *) G_malloc(sizeof(P_ISLE));
     if (Isle == NULL)
 	return NULL;
 
@@ -307,7 +307,7 @@
 
     num = area->alloc_lines + add;
 
-    p = realloc(area->lines, num * sizeof(plus_t));
+    p = G_realloc(area->lines, num * sizeof(plus_t));
     if (p == NULL)
 	return -1;
     area->lines = (plus_t *) p;
@@ -330,7 +330,7 @@
     G_debug(5, "dig_area_alloc_isle(): add = %d", add);
     num = area->alloc_isles + add;
 
-    p = realloc(area->isles, num * sizeof(plus_t));
+    p = G_realloc(area->isles, num * sizeof(plus_t));
     if (p == NULL)
 	return -1;
     area->isles = (plus_t *) p;
@@ -353,7 +353,7 @@
     G_debug(3, "dig_isle_alloc_line():");
     num = isle->alloc_lines + add;
 
-    p = realloc(isle->lines, num * sizeof(plus_t));
+    p = G_realloc(isle->lines, num * sizeof(plus_t));
     if (p == NULL)
 	return -1;
     isle->lines = (plus_t *) p;



More information about the grass-commit mailing list