1 diff -buNr gdbm-1.8.0.orig/falloc.c gdbm-1.8.0/falloc.c
2 --- gdbm-1.8.0.orig/falloc.c Tue May 18 20:16:06 1999
3 +++ gdbm-1.8.0/falloc.c Thu Apr 25 18:20:45 2002
8 + if (dbf->header->avail.count == dbf->header->avail.size)
10 + /* We're kind of stuck here, so we re-split the header in order to
11 + avoid crashing. Sigh. */
12 + push_avail_block(dbf);
15 /* Set up variables. */
16 new_el.av_adr = dbf->header->avail.next_block;
17 new_el.av_size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1)
19 if (num_bytes != new_el.av_size) _gdbm_fatal (dbf, "read error");
21 /* Add the elements from the new block to the header. */
22 - for (index = 0; index < new_blk->count; index++)
24 + while (index < new_blk->count)
26 + while(index < new_blk->count
27 + && dbf->header->avail.count < dbf->header->avail.size)
29 /* With luck, this will merge a lot of blocks! */
30 _gdbm_put_av_elem(new_blk->av_table[index],
31 dbf->header->avail.av_table,
32 - &dbf->header->avail.count, dbf->coalesce_blocks);
33 + &dbf->header->avail.count, TRUE);
36 + if (dbf->header->avail.count == dbf->header->avail.size)
38 + /* We're kind of stuck here, so we re-split the header in order to
39 + avoid crashing. Sigh. */
40 + push_avail_block(dbf);
44 /* Fix next_block, as well. */
46 /* We changed the header. */
47 dbf->header_changed = TRUE;
49 - /* Free the previous avail block. */
50 + /* Free the previous avail block. It is possible that the header table
51 + is now FULL, which will cause us to overflow it! */
52 + if (dbf->header->avail.count == dbf->header->avail.size)
54 + /* We're kind of stuck here, so we re-split the header in order to
55 + avoid crashing. Sigh. */
56 + push_avail_block(dbf);
59 _gdbm_put_av_elem (new_el, dbf->header->avail.av_table,
60 - &dbf->header->avail.count, dbf->coalesce_blocks);
61 + &dbf->header->avail.count, TRUE);