[PATCH] kbuild: Remove 2048 symbol limit in tkparse

Sam Ravnborg (sam@ravnborg.org)
Fri, 31 May 2002 22:41:51 +0200


--gE7i1rD7pdK0Ng3j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

tkparse limit the number of symbols to 2048.
This patch makes the array dynamic avoiding this problem in the future.
The problem showed up in one of the powerpc tree's.

Credit for this patch goes to Keith Owens, I just extracted it from kbuild-2.5.

Sam

--gE7i1rD7pdK0Ng3j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="no2048.diff"

--- tkparse.h.orig Fri May 31 22:03:24 2002
+++ tkparse.h Fri May 31 21:42:03 2002
@@ -115,7 +115,7 @@
char global_written;
};

-extern struct variable vartable[];
+extern struct variable *vartable;
extern int max_varnum;

/*
--- tkparse.c.orig Fri May 31 22:03:14 2002
+++ tkparse.c Fri May 31 21:42:03 2002
@@ -74,12 +74,12 @@


/*
- * Find index of a specyfic variable in the symbol table.
+ * Find index of a specific variable in the symbol table.
* Create a new entry if it does not exist yet.
*/
-#define VARTABLE_SIZE 4096
-struct variable vartable[VARTABLE_SIZE];
+struct variable *vartable;
int max_varnum = 0;
+static int vartable_size = 0;

int get_varnum( char * name )
{
@@ -88,8 +88,13 @@
for ( i = 1; i <= max_varnum; i++ )
if ( strcmp( vartable[i].name, name ) == 0 )
return i;
- if (max_varnum > VARTABLE_SIZE-1)
- syntax_error( "Too many variables defined." );
+ while (max_varnum+1 >= vartable_size) {
+ vartable = realloc(vartable, (vartable_size += 1000)*sizeof(*vartable));
+ if (!vartable) {
+ fprintf(stderr, "tkparse realloc vartable failed\n");
+ exit(1);
+ }
+ }
vartable[++max_varnum].name = malloc( strlen( name )+1 );
strcpy( vartable[max_varnum].name, name );
return max_varnum;
@@ -818,5 +823,6 @@
do_source ( "-" );
fix_conditionals ( config_list );
dump_tk_script ( config_list );
+ free(vartable);
return 0;
}

--gE7i1rD7pdK0Ng3j--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/