mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 09:06:02 +00:00
Remove invocation of v layer cache in r_io_desc_read ##io
This commit is contained in:
parent
49160ba96c
commit
1ce8535e90
@ -378,18 +378,10 @@ R_API bool r_io_cache_write_at(RIO *io, ut64 addr, ut8 *buf, int len) {
|
|||||||
|
|
||||||
R_API bool r_io_cache_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
|
R_API bool r_io_cache_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
|
||||||
r_return_val_if_fail (io && buf && (len > 0), false);
|
r_return_val_if_fail (io && buf && (len > 0), false);
|
||||||
bool ret = true;
|
|
||||||
if (io->va) {
|
|
||||||
ret = r_io_bank_read_at (io, io->bank, addr, buf, len);
|
|
||||||
} else if (io->desc) {
|
|
||||||
ret = (r_io_desc_read_at (io->desc, addr, buf, len) > 0);
|
|
||||||
}
|
|
||||||
if (!ret) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
RInterval itv = (RInterval){addr, len};
|
RInterval itv = (RInterval){addr, len};
|
||||||
RRBNode *node = _find_entry_ci_node (io->cache->tree, &itv);
|
RRBNode *node = _find_entry_ci_node (io->cache->tree, &itv);
|
||||||
IOCacheItem *ci = node? (IOCacheItem *)node->data: NULL;
|
IOCacheItem *ci = node? (IOCacheItem *)node->data: NULL;
|
||||||
|
const bool ret = !!ci;
|
||||||
while (ci && r_itv_overlap (ci->tree_itv[0], itv)) {
|
while (ci && r_itv_overlap (ci->tree_itv[0], itv)) {
|
||||||
node = r_rbnode_next (node);
|
node = r_rbnode_next (node);
|
||||||
RInterval its = r_itv_intersect (ci->tree_itv[0], itv);
|
RInterval its = r_itv_intersect (ci->tree_itv[0], itv);
|
||||||
@ -398,7 +390,7 @@ R_API bool r_io_cache_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
|
|||||||
r_itv_size (its));
|
r_itv_size (its));
|
||||||
ci = node? (IOCacheItem *)node->data: NULL;
|
ci = node? (IOCacheItem *)node->data: NULL;
|
||||||
}
|
}
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_API bool r_io_cache_at(RIO *io, ut64 addr) {
|
R_API bool r_io_cache_at(RIO *io, ut64 addr) {
|
||||||
|
@ -201,15 +201,8 @@ R_API int r_io_desc_read(RIODesc *desc, ut8 *buf, int len) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ut64 seek = r_io_desc_seek (desc, 0LL, R_IO_SEEK_CUR);
|
ut64 seek = r_io_desc_seek (desc, 0LL, R_IO_SEEK_CUR);
|
||||||
if (desc->io->cachemode) {
|
|
||||||
if (seek != UT64_MAX && r_io_cache_at (desc->io, seek)) {
|
|
||||||
return r_io_cache_read (desc->io, seek, buf, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int ret = r_io_plugin_read (desc, buf, len);
|
int ret = r_io_plugin_read (desc, buf, len);
|
||||||
if (ret > 0 && desc->io->cachemode) {
|
if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
|
||||||
r_io_cache_write (desc->io, seek, buf, len);
|
|
||||||
} else if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
|
|
||||||
ret = r_io_desc_cache_read (desc, seek, buf, ret);
|
ret = r_io_desc_cache_read (desc, seek, buf, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user