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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 18 11:02:13 PDT 2012


Author: glynn
Date: 2012-08-18 11:02:13 -0700 (Sat, 18 Aug 2012)
New Revision: 52725

Modified:
   grass/trunk/raster/r.mapcalc/expression.c
Log:
Eliminate fixed-size buffer


Modified: grass/trunk/raster/r.mapcalc/expression.c
===================================================================
--- grass/trunk/raster/r.mapcalc/expression.c	2012-08-18 15:55:00 UTC (rev 52724)
+++ grass/trunk/raster/r.mapcalc/expression.c	2012-08-18 18:02:13 UTC (rev 52725)
@@ -370,7 +370,8 @@
 
 static char *format_function(const expression * e, int prec)
 {
-    char *args[1024];
+    char **args = NULL;
+    int num_args = 0;
     char *result;
     int len;
     int i;
@@ -381,6 +382,10 @@
     len = strlen(e->data.func.name) + 3;
 
     for (i = 1; i <= e->data.func.argc; i++) {
+	if (i >= num_args) {
+	    num_args = i + 1000;
+	    args = G_realloc(args, num_args * sizeof(char *));
+	}
 	args[i] = format_expression_prec(e->data.func.args[i], 9);
 	if (i > 1)
 	    len += 2;



More information about the grass-commit mailing list