Merge pull request #1806 from tunz/tunz/cache

Cache index for find_memory_region
This commit is contained in:
lazymio 2023-03-21 19:20:50 +08:00 committed by GitHub
commit d9dcfc1264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
uc.c
View File

@ -1524,7 +1524,7 @@ MemoryRegion *find_memory_region(struct uc_struct *uc, uint64_t address)
if (i < uc->mapped_block_count &&
address >= uc->mapped_blocks[i]->addr &&
address < uc->mapped_blocks[i]->end) {
address <= uc->mapped_blocks[i]->end - 1) {
return uc->mapped_blocks[i];
}
@ -1532,8 +1532,10 @@ MemoryRegion *find_memory_region(struct uc_struct *uc, uint64_t address)
if (i < uc->mapped_block_count &&
address >= uc->mapped_blocks[i]->addr &&
address <= uc->mapped_blocks[i]->end - 1)
address <= uc->mapped_blocks[i]->end - 1) {
uc->mapped_block_cache_index = i;
return uc->mapped_blocks[i];
}
// not found
return NULL;