89 int cbaddr, written = 0;
90 if ((
len < 1) || !
desc || (desc_sz <= paddr) ||
97 if (paddr > (desc_sz -
len)) {
98 len = (
int)(desc_sz - paddr);
102 while (written <
len) {
111 ht_up_insert(
desc->cache, caddr, cache);
121 cache->
cached |= (0x1ULL << cbaddr);
128 cache->
cached |= (0x1ULL << cbaddr);
132 }
while (
len > written);
146 int cbaddr, amount = 0;
147 if ((
len < 1) || !
desc || (desc_sz <= paddr) || !
desc->io || !
desc->cache) {
153 if (paddr > (desc_sz -
len)) {
154 len = (
int)(desc_sz - paddr);
158 while (amount <
len) {
168 if (cache->
cached & (0x1ULL << cbaddr)) {
169 *ptr = cache->
cdata[cbaddr];
175 if (cache->
cached & (0x1ULL << cbaddr)) {
176 *ptr = cache->
cdata[cbaddr];
181 }
while (
len > amount);
210 if (dcache->
cached & (0x1LL << byteaddr)) {
221 cache->
itv.
addr = blockaddr + byteaddr;
260 desc->io->p_cache =
false;
264 rz_list_foreach (writes,
iter,
c) {
273 desc->io->p_cache =
true;
274 desc->io->desc = current;
288 if (dcache->
cached & (0x1LL << byteaddr)) {
310 current =
desc->io->desc;
312 desc->io->p_cache =
false;
314 ht_up_free(
desc->cache);
316 desc->io->p_cache =
true;
317 desc->io->desc = current;
331 if (
size <= blockaddr) {
332 ht_up_delete(
desc->cache,
k);
337 byteaddr = (
int)(
size - blockaddr) - 1;
352 ht_up_free(
desc->cache);
363 if (io && io->
files) {
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static bool __desc_fini_cb(void *user, void *data, ut32 id)
static bool __desc_cache_cleanup_cb(void *user, const ut64 k, const void *v)
const ut64 cleanup_masks[]
RZ_API bool rz_io_desc_cache_commit(RzIODesc *desc)
static void pcache_kv_free(HtUPKv *kv)
RZ_API void rz_io_desc_cache_fini(RzIODesc *desc)
RZ_API int rz_io_desc_cache_write(RzIODesc *desc, ut64 paddr, const ut8 *buf, int len)
RZ_API int rz_io_desc_cache_read(RzIODesc *desc, ut64 paddr, ut8 *buf, int len)
RZ_API RzList * rz_io_desc_cache_list(RzIODesc *desc)
RZ_API void rz_io_desc_cache_fini_all(RzIO *io)
static bool __desc_cache_commit_cb(void *user, const ut64 k, const void *v)
static bool __desc_cache_list_cb(void *user, const ut64 k, const void *v)
RZ_API void rz_io_desc_cache_cleanup(RzIODesc *desc)
RZ_API bool rz_io_desc_cache_init(RzIODesc *desc)
static void __riocache_free(void *user)
RZ_API void rz_event_send(RzEvent *ev, int type, void *data)
RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user)
RZ_API int rz_io_pwrite_at(RzIO *io, ut64 paddr, const ut8 *buf, int len)
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
#define RZ_IO_DESC_CACHE_SIZE
static ut64 rz_itv_begin(RzInterval itv)
static ut64 rz_itv_size(RzInterval itv)
void(* RzListFree)(void *ptr)
ut8 cdata[RZ_IO_DESC_CACHE_SIZE]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()