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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 18 05:07:47 EDT 2009


Author: hamish
Date: 2009-08-18 05:07:47 -0400 (Tue, 18 Aug 2009)
New Revision: 38777

Modified:
   grass/trunk/raster/r.li/r.li.daemon/daemon.c
   grass/trunk/raster/r.li/r.li.daemon/list.c
Log:
malloc to G_malloc, whitespace (merge from devbr6)

Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c	2009-08-18 09:04:49 UTC (rev 38776)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c	2009-08-18 09:07:47 UTC (rev 38777)
@@ -643,6 +643,7 @@
     return ERROR;
 }
 
+
 int next_Area(int parsed, list l, g_areas g, msg * m)
 {
     if (parsed == NORMAL) {
@@ -662,6 +663,7 @@
     }
 }
 
+
 int print_Output(int out, msg m)
 {
     if (m.type != DONE)
@@ -672,6 +674,7 @@
 
 	sprintf(s, "RESULT %i|%f\n", m.f.f_d.aid, m.f.f_d.res);
 	len = strlen(s);
+
 	if (write(out, s, len) == len)
 	    return 1;
 	else
@@ -679,6 +682,7 @@
     }
 }
 
+
 int error_Output(int out, msg m)
 {
     if (m.type != ERROR)
@@ -687,6 +691,7 @@
 	char s[100];
 
 	sprintf(s, "ERROR %i", m.f.f_d.aid);
+
 	if (write(out, s, strlen(s)) == strlen(s))
 	    return 1;
 	else
@@ -694,6 +699,7 @@
     }
 }
 
+
 int raster_Output(int fd, int aid, g_areas g, double res)
 {
     double toPut = res;
@@ -703,11 +709,14 @@
 	G_message(_("Cannot make lseek"));
 	return -1;
     }
+
     if (write(fd, &toPut, sizeof(double)) == 0)
 	return 1;
     else
 	return 0;
 }
+
+
 int write_raster(int mv_fd, int random_access, g_areas g)
 {
     int i = 0, j = 0, letti = 0;
@@ -719,24 +728,34 @@
     rows = g->rows;
     center = g->sf_x + ((int)g->cl / 2);
 
-    file_buf = malloc(cols * sizeof(double));
+    file_buf = G_malloc(cols * sizeof(double));
     lseek(random_access, 0, SEEK_SET);
+
     cell_buf = Rast_allocate_d_buf();
     Rast_set_d_null_value(cell_buf, G_window_cols() + 1);
+
     for (i = 0; i < g->sf_y + ((int)g->rl / 2); i++) {
 	Rast_put_row(mv_fd, cell_buf, DCELL_TYPE);
     }
+
     for (i = 0; i < rows; i++) {
 	letti = read(random_access, file_buf, (cols * sizeof(double)));
+
 	if (letti == -1)
 	    G_message("%s", strerror(errno));
+
 	for (j = 0; j < cols; j++) {
 	    cell_buf[j + center] = file_buf[j];
 	}
+
 	Rast_put_row(mv_fd, cell_buf, DCELL_TYPE);
+
     }
+
     Rast_set_d_null_value(cell_buf, G_window_cols() + 1);
+
     for (i = 0; i < G_window_rows() - g->sf_y - g->rows; i++)
 	Rast_put_row(mv_fd, cell_buf, DCELL_TYPE);
+
     return 1;
 }

Modified: grass/trunk/raster/r.li/r.li.daemon/list.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/list.c	2009-08-18 09:04:49 UTC (rev 38776)
+++ grass/trunk/raster/r.li/r.li.daemon/list.c	2009-08-18 09:07:47 UTC (rev 38777)
@@ -29,11 +29,13 @@
 {
     node new;
 
-    new = malloc(sizeof(node));
-    new->m = malloc(sizeof(msg));
+    new = G_malloc(sizeof(node));
+    new->m = G_malloc(sizeof(msg));
+
     if (new != NULL) {
 	memcpy(new->m, &mess, sizeof(msg));
 	new->next = new->prev = NULL;
+
 	if (l->head == NULL) {
 	    l->head = l->tail = new;
 	}
@@ -45,6 +47,7 @@
     }
     else
 	G_message(_("Out of memory"));
+
     l->size++;
 }
 



More information about the grass-commit mailing list