Fix a bug in reading usage maps

This commit is contained in:
whydoubt 2004-08-28 23:00:25 +00:00
parent 01e7458954
commit c5e11e5445
3 changed files with 17 additions and 13 deletions

View File

@ -1,6 +1,8 @@
Sat Aug 28 14:21:41 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* src/libmdb/data.c: Fix mdb_read_next_dpg
Correct long int display length
* src/libmdb/data.c:
* src/libmdb/map.c: Fix a bug in reading usage maps
Sat Aug 28 00:20:44 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* src/libmdb/write.c: Jump table packing/cracking improvements

View File

@ -269,16 +269,20 @@ int mdb_read_next_dpg(MdbTableDef *table)
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
int next_pg;
int map_type;
#ifndef SLOW_READ
next_pg = mdb_map_find_next(mdb, table->usage_map,
table->map_sz, table->cur_phys_pg);
if (next_pg && mdb_read_pg(mdb, next_pg)) {
table->cur_phys_pg = next_pg;
return table->cur_phys_pg;
if (next_pg >= 0) {
if (mdb_read_pg(mdb, next_pg)) {
table->cur_phys_pg = next_pg;
return table->cur_phys_pg;
} else {
return 0;
}
}
fprintf(stderr, "Warning: defaulting to brute force read\n");
#endif
/* can't do a fast read, go back to the old way */
do {

View File

@ -33,7 +33,8 @@ mdb_map_find_next0(MdbHandle *mdb, unsigned char *map, unsigned int map_sz, guin
usage_bitmap = map + 5;
usage_bitlen = (map_sz - 5) * 8;
for (i=start_pg-pgnum+1; i<usage_bitlen; i++) {
i = (start_pg >= pgnum) ? start_pg-pgnum+1 : 0;
for (; i<usage_bitlen; i++) {
if (usage_bitmap[i/8] & (1 << (i%8))) {
return pgnum + i;
}
@ -85,17 +86,14 @@ mdb_map_find_next1(MdbHandle *mdb, unsigned char *map, unsigned int map_sz, guin
guint32
mdb_map_find_next(MdbHandle *mdb, unsigned char *map, unsigned int map_sz, guint32 start_pg)
{
int map_type;
map_type = map[0];
if (map_type==0) {
if (map[0] == 0) {
return mdb_map_find_next0(mdb, map, map_sz, start_pg);
} else if (map_type==1) {
} else if (map[0] == 1) {
return mdb_map_find_next1(mdb, map, map_sz, start_pg);
} else {
fprintf(stderr,"Warning: unrecognized usage map type: %d, defaulting to brute force read\n",map[0]);
}
return 0;
fprintf(stderr, "Warning: unrecognized usage map type: %d\n", map[0]);
return -1;
}
guint32
mdb_alloc_page(MdbTableDef *table)