瀏覽代碼

Make r3.mapcalc work on 64-bit systems (where a void* won't fit into an int)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32268 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 17 年之前
父節點
當前提交
c5b78ce38f
共有 1 個文件被更改,包括 15 次插入15 次删除
  1. 15 15
      raster/r.mapcalc/map3.c

+ 15 - 15
raster/r.mapcalc/map3.c

@@ -49,6 +49,10 @@ static map *maps;
 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 max_col = -INT_MAX;
 
 /****************************************************************************/
 
-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 @@ void close_maps(void)
 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 @@ int open_output_map(const char *name, int res_type)
 	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"));