[GRASS-SVN] r36403 - grass/trunk/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 17 10:47:57 EDT 2009


Author: mmetz
Date: 2009-03-17 10:47:56 -0400 (Tue, 17 Mar 2009)
New Revision: 36403

Modified:
   grass/trunk/lib/vector/diglib/plus_area.c
   grass/trunk/lib/vector/diglib/plus_line.c
   grass/trunk/lib/vector/diglib/struct_alloc.c
Log:
TODO: free structures done in diglib, part 2

Modified: grass/trunk/lib/vector/diglib/plus_area.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_area.c	2009-03-17 14:46:11 UTC (rev 36402)
+++ grass/trunk/lib/vector/diglib/plus_area.c	2009-03-17 14:47:56 UTC (rev 36403)
@@ -424,7 +424,8 @@
 	}
     }
 
-    /* TODO: free structures */
+    /* free structures */
+    dig_free_area(Area);
     plus->Area[area] = NULL;
     return 1;
 }
@@ -778,8 +779,8 @@
 	}
     }
 
-    /* TODO: free structures */
-
+    /* free structures */
+    dig_free_isle(Isle);
     plus->Isle[isle] = NULL;
 
     return 1;

Modified: grass/trunk/lib/vector/diglib/plus_line.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_line.c	2009-03-17 14:46:11 UTC (rev 36402)
+++ grass/trunk/lib/vector/diglib/plus_line.c	2009-03-17 14:47:56 UTC (rev 36403)
@@ -188,7 +188,6 @@
     P_LINE *Line;
     P_NODE *Node;
 
-    /* TODO: free structures */
     G_debug(3, "dig_del_line() line =  %d", line);
 
     Line = plus->Line[line];
@@ -211,6 +210,8 @@
     if (Node->n_lines == 0) {
 	G_debug(3, "    node %d has 0 lines -> delete", Line->N1);
 	dig_spidx_del_node(plus, Line->N1);
+	/* free structures */
+	dig_free_node(Node);
 	plus->Node[Line->N1] = NULL;
     }
     else {
@@ -235,6 +236,8 @@
 	if (Node->n_lines == 0) {
 	    G_debug(3, "    node %d has 0 lines -> delete", Line->N2);
 	    dig_spidx_del_node(plus, Line->N2);
+	    /* free structures */
+	    dig_free_node(Node);
 	    plus->Node[Line->N2] = NULL;
 	}
 	else {
@@ -244,6 +247,7 @@
     }
 
     /* Delete line */
+    dig_free_line(Line);
     plus->Line[line] = NULL;
 
     return 0;

Modified: grass/trunk/lib/vector/diglib/struct_alloc.c
===================================================================
--- grass/trunk/lib/vector/diglib/struct_alloc.c	2009-03-17 14:46:11 UTC (rev 36402)
+++ grass/trunk/lib/vector/diglib/struct_alloc.c	2009-03-17 14:47:56 UTC (rev 36403)
@@ -35,6 +35,7 @@
  ** Allocate array space to add 'add' elements
  */
 
+/* TODO: use G_malloc and friends instead of malloc et al.? */
 
 /* allocate new node structure */
 P_NODE *dig_alloc_node()
@@ -53,6 +54,14 @@
     return (Node);
 }
 
+/* free node structure */
+void dig_free_node(P_NODE *Node)
+{
+    free(Node->lines);
+    free(Node->angles);
+    free(Node);
+}
+
 /* dig_node_alloc_line (node, add)
  **     allocate space in  P_node,  lines and angles arrays to add 'add' more
  **     lines
@@ -118,6 +127,12 @@
     return (Line);
 }
 
+/* free line structure */
+void dig_free_line(P_LINE *Line)
+{
+    free(Line);
+}
+
 /* Reallocate array of pointers to lines.
  *  Space for 'add' number of lines is added.
  * 
@@ -207,6 +222,14 @@
     return (Area);
 }
 
+/* free area structure */
+void dig_free_area(P_AREA *Area)
+{
+    free(Area->lines);
+    free(Area->isles);
+    free(Area);
+}
+
 /* alloc new isle structure */
 P_ISLE *dig_alloc_isle()
 {
@@ -225,6 +248,12 @@
     return (Isle);
 }
 
+/* free isle structure */
+void dig_free_isle(P_ISLE *Isle)
+{
+    free(Isle->lines);
+    free(Isle);
+}
 
 /* allocate room for  'num'   X and Y  arrays in struct line_pnts 
  **   returns -1 on out of memory 



More information about the grass-commit mailing list