[GRASS-SVN] r37247 - grass/branches/develbranch_6/vector/v.label.sa

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 16 12:57:18 EDT 2009


Author: wolf
Date: 2009-05-16 12:57:17 -0400 (Sat, 16 May 2009)
New Revision: 37247

Modified:
   grass/branches/develbranch_6/vector/v.label.sa/font.c
   grass/branches/develbranch_6/vector/v.label.sa/labels.c
   grass/branches/develbranch_6/vector/v.label.sa/labels.h
Log:
Fixed includes so that G_malloc and friends work. Also changed all allocs to use G_malloc and friends

Modified: grass/branches/develbranch_6/vector/v.label.sa/font.c
===================================================================
--- grass/branches/develbranch_6/vector/v.label.sa/font.c	2009-05-16 16:42:34 UTC (rev 37246)
+++ grass/branches/develbranch_6/vector/v.label.sa/font.c	2009-05-16 16:57:17 UTC (rev 37247)
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <grass/gis.h>
+#include <grass/gisdefs.h>
 #include <grass/glocale.h>
 #include <grass/freetypecap.h>
 #include "labels.h"

Modified: grass/branches/develbranch_6/vector/v.label.sa/labels.c
===================================================================
--- grass/branches/develbranch_6/vector/v.label.sa/labels.c	2009-05-16 16:42:34 UTC (rev 37246)
+++ grass/branches/develbranch_6/vector/v.label.sa/labels.c	2009-05-16 16:57:17 UTC (rev 37247)
@@ -66,7 +66,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)
@@ -128,7 +128,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"));
 	    }
@@ -153,7 +153,7 @@
 	if (cat < 0)
 	    continue;		/* no cat for this field */
 
-	sql = G_malloc(sql_len);
+	sql = (char *) G_malloc(sql_len);
 	/* Read label from database */
 	if (p->overlap->answer[0] != '\0') {
 	    sprintf(sql, "select %s,%s from %s where %s = %d",
@@ -167,7 +167,7 @@
 	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)
@@ -407,7 +407,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.");
     }
@@ -550,8 +550,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.");
     }
@@ -761,15 +761,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 */
@@ -783,7 +783,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;
 	}
@@ -1234,7 +1234,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");
@@ -1247,7 +1247,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");

Modified: grass/branches/develbranch_6/vector/v.label.sa/labels.h
===================================================================
--- grass/branches/develbranch_6/vector/v.label.sa/labels.h	2009-05-16 16:42:34 UTC (rev 37246)
+++ grass/branches/develbranch_6/vector/v.label.sa/labels.h	2009-05-16 16:57:17 UTC (rev 37247)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <math.h>
 #include <grass/gis.h>
+#include <grass/gisdefs.h>
 #include <grass/display.h>
 #include <grass/raster.h>
 #include <grass/Vect.h>



More information about the grass-commit mailing list