Bläddra i källkod

malloc to G_malloc, whitespace (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38777 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 16 år sedan
förälder
incheckning
bf64402700
2 ändrade filer med 25 tillägg och 3 borttagningar
  1. 20 1
      raster/r.li/r.li.daemon/daemon.c
  2. 5 2
      raster/r.li/r.li.daemon/list.c

+ 20 - 1
raster/r.li/r.li.daemon/daemon.c

@@ -643,6 +643,7 @@ int disposeAreas(list l, g_areas g, char *def)
     return ERROR;
 }
 
+
 int next_Area(int parsed, list l, g_areas g, msg * m)
 {
     if (parsed == NORMAL) {
@@ -662,6 +663,7 @@ int next_Area(int parsed, list l, g_areas g, msg * m)
     }
 }
 
+
 int print_Output(int out, msg m)
 {
     if (m.type != DONE)
@@ -672,6 +674,7 @@ int print_Output(int out, msg m)
 
 	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 print_Output(int out, msg m)
     }
 }
 
+
 int error_Output(int out, msg m)
 {
     if (m.type != ERROR)
@@ -687,6 +691,7 @@ int error_Output(int out, msg m)
 	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 error_Output(int out, msg m)
     }
 }
 
+
 int raster_Output(int fd, int aid, g_areas g, double res)
 {
     double toPut = res;
@@ -703,11 +709,14 @@ int raster_Output(int fd, int aid, g_areas g, double res)
 	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 @@ int write_raster(int mv_fd, int random_access, g_areas g)
     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;
 }

+ 5 - 2
raster/r.li/r.li.daemon/list.c

@@ -29,11 +29,13 @@ void insertNode(list l, msg mess)
 {
     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 @@ void insertNode(list l, msg mess)
     }
     else
 	G_message(_("Out of memory"));
+
     l->size++;
 }