Add wc--* command to purge all cache layers ##io

This commit is contained in:
pancake 2023-06-15 20:43:17 +02:00 committed by GitHub
parent b78a39855f
commit 8290315c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 10 deletions

View File

@ -1439,7 +1439,13 @@ static int cmd_wc(void *data, const char *input) {
break;
case '-': // "wc-"
if (input[1] == '-') { // "wc--"
r_io_cache_pop (core->io);
if (input[2] == '*') {
while (r_io_cache_pop (core->io)) {
// nothing here
}
} else {
r_io_cache_pop (core->io);
}
} else if (input[1] == '?') {
r_core_cmd_help_match (core, help_msg_wc, "wc-", false);
} else {

View File

@ -531,9 +531,9 @@ R_API int r_io_cache_invalidate(RIO *io, ut64 from, ut64 to, bool many);
R_API void r_io_cache_commit(RIO *io, ut64 from, ut64 to, bool many);
// cache layers
R_API void r_io_cache_push(RIO *io);
R_API void r_io_cache_pop(RIO *io);
R_API void r_io_cache_undo(RIO *io);
R_API void r_io_cache_redo(RIO *io);
R_API bool r_io_cache_pop(RIO *io);
R_API bool r_io_cache_undo(RIO *io);
R_API bool r_io_cache_redo(RIO *io);
/* io/p_cache.c */
R_API bool r_io_desc_cache_init(RIODesc *desc);

View File

@ -517,17 +517,19 @@ R_API void r_io_cache_push(RIO *io) {
r_list_append (io->cache.layers, iocache_layer_new ());
}
R_API void r_io_cache_pop(RIO *io) {
R_API bool r_io_cache_pop(RIO *io) {
if (!r_list_empty (io->cache.layers)) {
RIOCacheLayer *cl = r_list_pop (io->cache.layers);
iocache_layer_free (cl);
return true;
}
return false;
}
R_API void r_io_cache_undo(RIO *io) { // "wcu"
r_return_if_fail (io);
R_API bool r_io_cache_undo(RIO *io) { // "wcu"
r_return_val_if_fail (io, false);
if (r_list_empty (io->cache.layers)) {
return;
return false;
}
RIOCacheLayer *layer = r_list_last (io->cache.layers);
void **iter;
@ -547,8 +549,10 @@ R_API void r_io_cache_undo(RIO *io) { // "wcu"
free_elem (c);
break;
}
return true;
}
R_API void r_io_cache_redo(RIO *io) { // "wcU"
// TODO
R_API bool r_io_cache_redo(RIO *io) { // "wcU"
// TODO : not implemented
return false;
}