From 7d2f8e4d3ea3a558ba7401270da8e109c4fb4031 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 10 Aug 1987 10:20:52 +0000 Subject: [PATCH] dynamic table sizes, commons in ranlib table --- util/arch/archiver.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 92fc31ed2..d62c23f2f 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -30,16 +30,15 @@ static char RcsId[] = "$Header$"; #include #define MAGIC_NUMBER AALMAG #ifdef AAL -#define TABSZ 2000 /* maximum # of ranlib table entries */ -#define STRTABSZ 8*TABSZ /* maximum size of string table */ long offset; -struct ranlib tab[TABSZ]; +struct ranlib *tab; long tnum = 0; -char tstrtab[STRTABSZ]; +char *tstrtab; long tssiz = 0; -char *malloc(), *strcpy(), *strncpy(); +char *malloc(), *realloc(), *strcpy(), *strncpy(); long lseek(); long time(); +unsigned int tabsz, strtabsz; #endif AAL #else #define MAGIC_NUMBER ARMAG @@ -233,6 +232,13 @@ char *argv[]; ) { mktemp(temp_arch); } +#ifdef AAL + tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib)); + tstrtab = malloc(4096); + if (!tab || !tstrtab) error(TRUE,"Out of core\n"); + tabsz = 512; + strtabsz = 4096; +#endif signal(SIGINT, catch); get(argc, argv); @@ -665,11 +671,14 @@ do_names(headp) p->on_mptr = xxx + p->on_foff; /* * Only enter names that are exported and are really - * defined. + * defined. Also enter common names. Note, that + * this might cause problems when the name is really + * defined in a later file, with a value != 0. + * However, this problem also exists on the Unix + * ranlib archives. */ if ( (p->on_type & S_EXT) && - (p->on_type & S_TYP) != S_UND && - !(p->on_type & S_COM) + (p->on_type & S_TYP) != S_UND ) enter_name(p); p++; @@ -683,16 +692,21 @@ enter_name(namep) { register char *cp; - if (tnum >= TABSZ) { - error(TRUE, "symbol table overflow\n"); + if (tnum >= tabsz) { + tab = (struct ranlib *) + realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib)); + if (! tab) error(TRUE, "Out of core\n"); } tab[tnum].ran_off = tssiz; tab[tnum].ran_pos = offset; - for (cp = namep->on_mptr; tstrtab[tssiz++] = *cp++;) - if (tssiz >= STRTABSZ) { - error(TRUE, "string table overflow\n"); + for (cp = namep->on_mptr; *cp; cp++) { + if (tssiz >= strtabsz) { + tstrtab = realloc(tstrtab, (strtabsz += 4096)); + if (! tstrtab) error(TRUE, "string table overflow\n"); } + tstrtab[tssiz++] = *cp; + } tnum++; } #endif AAL -- 2.34.1