Skip to contentSkip to conversation

kbuild: Remove 2048 symbol limit in tkparse

PATCH In review Sam Ravnborg 2 participants 2 messages May 31, 2002 – Jun 1, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Remove 2048 symbol limit in tkparse

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

tkparse.h renamed from tkparse.h.orig +1 -1
@@ -115,7 +115,7 @@
     char	global_written;
 };
 
-extern struct variable vartable[];
+extern struct variable *vartable;
 extern int max_varnum;
 
 /*
tkparse.c renamed from tkparse.c.orig +11 -5
@@ -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;
 }
#1 lore raw
Quoted 3 lines · Sam Ravnborg

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.

Thanks, I'll look at this (and the other patches) and submit it to Linus (assuming I don't find anything wrong with it), if he didn't already merge it.

--Kai