[GRASS-SVN] r37394 - grass/trunk/vector/v.label.sa

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 23 04:29:05 EDT 2009


Author: neteler
Date: 2009-05-23 04:29:05 -0400 (Sat, 23 May 2009)
New Revision: 37394

Modified:
   grass/trunk/vector/v.label.sa/labels.c
Log:
Fixed includes so that G_malloc and friends work. Also changed all allocs to use G_malloc and friends (merge from develbranch_6, r37247, r37393)

Modified: grass/trunk/vector/v.label.sa/labels.c
===================================================================
--- grass/trunk/vector/v.label.sa/labels.c	2009-05-23 08:26:06 UTC (rev 37393)
+++ grass/trunk/vector/v.label.sa/labels.c	2009-05-23 08:29:05 UTC (rev 37394)
@@ -60,7 +60,7 @@
 
     G_debug(1, "Need to allocate %d bytes of memory",
 	    sizeof(label_t) * label_sz);
-    labels = malloc(sizeof(label_t) * label_sz);
+    labels = (label_t *) G_malloc(sizeof(label_t) * label_sz);
     G_debug(1, "labels=%p", labels);
 
     if (labels == NULL)
@@ -121,7 +121,7 @@
 	    label_sz += 100;
 	    G_debug(1, "Need to resize %p to %d bytes of memory",
 		    (void *)labels, sizeof(label_t) * label_sz);
-	    labels = realloc(labels, sizeof(label_t) * label_sz);
+	    labels = G_realloc(labels, sizeof(label_t) * label_sz);
 	    if (labels == NULL) {
 		G_fatal_error(_("Cannot allocate more memory"));
 	    }
@@ -146,14 +146,14 @@
 	if (cat < 0)
 	    continue;		/* no cat for this field */
 
-	sql = G_malloc(sql_len);
+	sql = (char *) G_malloc(sql_len);
 	/* Read label from database */
 	sprintf(sql, "select %s from %s where %s = %d", p->column->answer,
 		fi->table, fi->key, cat);
 	G_debug(3, "SQL: %s", sql);
 	db_init_string(&query);
 	db_set_string(&query, sql);
-	free(sql);
+	G_free(sql);
 
 	if (db_open_select_cursor(driver, &query, &cursor, DB_SEQUENTIAL) !=
 	    DB_OK)
@@ -367,7 +367,7 @@
     int i;
     label_candidate_t *candidates;
 
-    candidates = calloc(19, sizeof(label_candidate_t));
+    candidates = G_calloc(19, sizeof(label_candidate_t));
     if (candidates == NULL) {
 	G_fatal_error("Cannot allocate memory.");
     }
@@ -510,8 +510,8 @@
 
 	return;
     }
-    above_candidates = calloc(n, sizeof(label_candidate_t));
-    below_candidates = calloc(n, sizeof(label_candidate_t));
+    above_candidates = G_calloc(n, sizeof(label_candidate_t));
+    below_candidates = G_calloc(n, sizeof(label_candidate_t));
     if ((above_candidates == NULL) || (below_candidates == NULL)) {
 	G_fatal_error("Cannot allocate memory.");
     }
@@ -721,15 +721,15 @@
 	return;
     }
 
-    candidates = calloc(n * 2, sizeof(label_candidate_t));
+    candidates = G_calloc(n * 2, sizeof(label_candidate_t));
     for (i = 0; i < n; i++) {
 	memcpy(&candidates[i * 2], &above_candidates[i],
 	       sizeof(label_candidate_t));
 	memcpy(&candidates[i * 2 + 1], &below_candidates[i],
 	       sizeof(label_candidate_t));
     }
-    free(above_candidates);
-    free(below_candidates);
+    G_free(above_candidates);
+    G_free(below_candidates);
 
     n_c = n * 2;
     /* pick the 32 best candidates */
@@ -743,7 +743,7 @@
 	    Vect_destroy_line_struct(candidates[i].swathline);
 	}
 
-	tmp = realloc(candidates, sizeof(label_candidate_t) * 32);
+	tmp = G_realloc(candidates, sizeof(label_candidate_t) * 32);
 	if (tmp != NULL) {
 	    candidates = tmp;
 	}
@@ -1194,7 +1194,7 @@
 			label_intersection_t *li;
 
 			n = ++(labels[i].candidates[j].n_intersections);
-			li = realloc(labels[i].candidates[j].intersections,
+			li = G_realloc(labels[i].candidates[j].intersections,
 				     n * sizeof(label_intersection_t));
 			if (li == NULL)
 			    G_fatal_error("\nUnable to allocate memory\n");
@@ -1207,7 +1207,7 @@
 			}
 			labels[i].candidates[j].intersections = li;
 			n = ++(labels[k].candidates[l].n_intersections);
-			li = realloc(labels[k].candidates[l].intersections,
+			li = G_realloc(labels[k].candidates[l].intersections,
 				     n * sizeof(label_intersection_t));
 			if (li == NULL)
 			    G_fatal_error("\nUnable to allocate memory\n");



More information about the grass-commit mailing list