mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-06-28 15:39:02 +08:00
Fix a bug in reading usage maps
This commit is contained in:
parent
01e7458954
commit
c5e11e5445
@ -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
|
||||
|
@ -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)) {
|
||||
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 {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user