[GRASS-SVN] r38758 - grass/trunk/raster/r.li/r.li.daemon

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 17 00:22:17 EDT 2009


Author: hamish
Date: 2009-08-17 00:22:17 -0400 (Mon, 17 Aug 2009)
New Revision: 38758

Modified:
   grass/trunk/raster/r.li/r.li.daemon/worker.c
Log:
merge r38757 from devbr6:
 detect & bailout on error (trac #718);
 use G_malloc();
 +new debug msg


Modified: grass/trunk/raster/r.li/r.li.daemon/worker.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/worker.c	2009-08-17 04:18:46 UTC (rev 38757)
+++ grass/trunk/raster/r.li/r.li.daemon/worker.c	2009-08-17 04:22:17 UTC (rev 38758)
@@ -57,13 +57,15 @@
     fm = G_malloc(sizeof(struct fcell_memory_entry));
     dm = G_malloc(sizeof(struct dcell_memory_entry));
     pid = getpid();
-    ad = malloc(sizeof(struct area_entry));
+    ad = G_malloc(sizeof(struct area_entry));
+
     /* open raster map */
     fd = Rast_open_old(raster, "");
     if (Rast_get_cellhd(raster, "", &hd) == -1) {
 	G_message(_("CHILD[pid = %i] cannot open raster map"), pid);
 	exit(EXIT_FAILURE);
     }
+
     /* read data type to allocate cache */
     data_type = Rast_map_type(raster, "");
     /* calculate rows in cache */
@@ -111,6 +113,7 @@
 
     /* receive loop */
     receive(rec_ch, &toReceive);
+
     while (toReceive.type != TERM) {
 	if (toReceive.type == AREA) {
 	    aid = toReceive.f.f_ma.aid;
@@ -121,9 +124,7 @@
 	    ad->raster = raster;
 	    ad->mask = -1;
 	}
-	else {
-	    /* toReceive.type == MASKEDAREA */
-
+	else if (toReceive.type == MASKEDAREA) {
 	    aid = toReceive.f.f_ma.aid;
 	    ad->x = toReceive.f.f_ma.x;
 	    ad->y = toReceive.f.f_ma.y;
@@ -148,9 +149,11 @@
 		    G_message(_("CHILD[pid = %i]: unable to open <%s> mask ... continuing without!"),
 			      pid, toReceive.f.f_ma.mask);
 		}
-
 	    }
 	}
+	else
+	    G_fatal_error("Program error, worker() toReceive.type=%d",
+			  toReceive.type);
 
 	/* memory menagement */
 	if (ad->rl > used) {
@@ -226,8 +229,11 @@
     CELL *old;
     double add_row, add_col;
 
-    buf = malloc(cl * sizeof(int));
+    buf = G_malloc(cl * sizeof(int));
 
+    G_debug(3, "daemon mask preproc: raster=[%s] mask=[%s]  rl=%d cl=%d",
+	    raster, mask, rl, cl);
+
     /* open raster */
     if (Rast_get_cellhd(raster, "", &cell) == -1)
 	return NULL;



More information about the grass-commit mailing list