[GRASS-SVN] r32277 - grass/branches/develbranch_6/raster/r.mapcalc

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 25 03:53:50 EDT 2008


Author: martinl
Date: 2008-07-25 03:53:50 -0400 (Fri, 25 Jul 2008)
New Revision: 32277

Modified:
   grass/branches/develbranch_6/raster/r.mapcalc/map3.c
Log:
glynn: Make r3.mapcalc work on 64-bit systems (where a void* won't fit into an int) [merged from trunk, r32268]


Modified: grass/branches/develbranch_6/raster/r.mapcalc/map3.c
===================================================================
--- grass/branches/develbranch_6/raster/r.mapcalc/map3.c	2008-07-25 02:16:44 UTC (rev 32276)
+++ grass/branches/develbranch_6/raster/r.mapcalc/map3.c	2008-07-25 07:53:50 UTC (rev 32277)
@@ -49,6 +49,10 @@
 static int num_maps;
 static int max_maps;
 
+static void **omaps;
+static int num_omaps;
+static int max_omaps;
+
 static unsigned char *red, *grn, *blu;
 static unsigned char *set;
 
@@ -59,16 +63,6 @@
 
 /****************************************************************************/
 
-static int handle_to_fd(void *handle)
-{
-	return (int) handle;
-}
-
-static void *fd_to_handle(int fd)
-{
-	return (void *) fd;
-}
-
 static void read_row(void *handle, char *buf, int type, int depth, int row)
 {
 	int i;
@@ -586,7 +580,6 @@
 int open_output_map(const char *name, int res_type)
 {
 	void *handle;
-	int fd;
 
 	G3d_setFileType(res_type == FCELL_TYPE ? FCELL_TYPE : DCELL_TYPE);
 
@@ -599,21 +592,28 @@
 	if (!handle)
 		G_fatal_error(_("Unable to create raster map <%s>"), name);
 
-	fd = handle_to_fd(handle);
 
-	return fd;
+	if (num_omaps >= max_omaps)
+	{
+		max_omaps += 10;
+		omaps = G_realloc(omaps, max_omaps * sizeof(void *));
+	}
+
+	omaps[num_omaps] = handle;
+
+	return num_omaps++;
 }
 
 void put_map_row(int fd, void *buf, int res_type)
 {
-	void *handle = fd_to_handle(fd);
+	void *handle = omaps[fd];
 
 	write_row(handle, buf, res_type, current_depth, current_row);
 }
 
 void close_output_map(int fd)
 {
-	void *handle = fd_to_handle(fd);
+	void *handle = omaps[fd];
 
 	if (!G3d_closeCell(handle))
 		G_fatal_error(_("Unable to close output raster map"));



More information about the grass-commit mailing list