extern item_t *fb_ptr[4*FB_SIZE];
#ifdef THREE_PASS
-extern char bittab[BITMAX>>3];
- /* one bit per small-large decision */
-extern long nbits; /* number of decisions so far */
+#define BITCHUNK (8 * MEMINCR)
+extern int nbits;
+extern int bitindex; /* bitindex * MEMINCR * 8 + nbits gives
+ number of decisions so far
+ */
#endif
#ifdef LISTING
register nfile = 0;
#endif
+#ifdef THREE_PASS
+ bitindex = -1;
+ nbits = BITCHUNK;
+#endif
+
tempfile = fftemp(temppath, "asTXXXXXX");
#ifdef LISTING
listmode = dflag;
listeoln = 1;
#endif
#ifdef THREE_PASS
- nbits = 0;
+ bitindex = -1;
+ nbits = BITCHUNK;
#endif
for (i = 0; i < FB_SIZE; i++)
fb_ptr[FB_FORW+i] = fb_ptr[FB_HEAD+i];
/* ---------- code optimization ---------- */
#ifdef THREE_PASS
+#define PBITTABSZ 128
+static char *pbittab[PBITTABSZ];
+
small(fitsmall, gain)
{
register bit;
nosect();
if (bflag)
return(0);
- if (nbits == BITMAX) {
- static int w_given;
- if (pass == PASS_1 && ! w_given) {
- w_given = 1;
- warning("bit table overflow");
+ if (nbits == BITCHUNK) {
+ bitindex++;
+ nbits = 0;
+ if (bitindex == PBITTABSZ) {
+ static int w_given;
+ if (pass == PASS_1 && ! w_given) {
+ w_given = 1;
+ warning("bit table overflow");
+ }
+ return(0);
}
- return(0);
+ if (pbittab[bitindex] == 0 && pass == PASS_1) {
+ if ((pbittab[bitindex] = malloc(MEMINCR)) == 0) {
+ static int w2_given;
+
+ if (!w2_given) {
+ w2_given = 1;
+ warning("out of space for bit table");
+ }
+ }
+ }
+ if (pbittab[bitindex] == 0)
+ return (0);
}
- p = &bittab[(int) (nbits>>3)];
- bit = 1 << ((int)nbits&7);
+ bit = 1 << (nbits&7);
+ p = pbittab[bitindex]+(nbits>>3);
nbits++;
switch (pass) {
case PASS_1: