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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 19 01:12:54 PDT 2012


Author: neteler
Date: 2012-08-19 01:12:53 -0700 (Sun, 19 Aug 2012)
New Revision: 52727

Modified:
   grass/branches/develbranch_6/raster/r.mapcalc/expression.c
Log:
Eliminate fixed-size buffer (backport from trunk, r52725)

Modified: grass/branches/develbranch_6/raster/r.mapcalc/expression.c
===================================================================
--- grass/branches/develbranch_6/raster/r.mapcalc/expression.c	2012-08-19 08:12:40 UTC (rev 52726)
+++ grass/branches/develbranch_6/raster/r.mapcalc/expression.c	2012-08-19 08:12:53 UTC (rev 52727)
@@ -373,7 +373,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;
@@ -384,6 +385,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