[GRASS-SVN] r32268 - grass/trunk/raster/r.mapcalc

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 24 13:14:51 EDT 2008


Author: glynn
Date: 2008-07-24 13:14:50 -0400 (Thu, 24 Jul 2008)
New Revision: 32268

Modified:
   grass/trunk/raster/r.mapcalc/map3.c
Log:
Make r3.mapcalc work on 64-bit systems (where a void* won't fit into an int)


Modified: grass/trunk/raster/r.mapcalc/map3.c
===================================================================
--- grass/trunk/raster/r.mapcalc/map3.c	2008-07-24 16:52:45 UTC (rev 32267)
+++ grass/trunk/raster/r.mapcalc/map3.c	2008-07-24 17:14:50 UTC (rev 32268)
@@ -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