mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 14:28:07 +00:00
Add r_core_bind_cons() (#10715)
This commit is contained in:
parent
93d91205c4
commit
d3a3940d75
@ -715,6 +715,7 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
if (!r_core_file_open (core2, file2, 0, 0LL)) {
|
||||
eprintf ("Cannot open diff file '%s'\n", file2);
|
||||
r_core_free (core2);
|
||||
r_core_bind_cons (core);
|
||||
return false;
|
||||
}
|
||||
// TODO: must replicate on core1 too
|
||||
@ -729,6 +730,7 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
/* exchange a segfault with a memleak */
|
||||
core2->config = NULL;
|
||||
r_core_free (core2);
|
||||
r_core_bind_cons (core);
|
||||
}
|
||||
break;
|
||||
case 'u': // "cu"
|
||||
|
@ -2087,17 +2087,11 @@ R_API bool r_core_init(RCore *core) {
|
||||
core->print->cons = core->cons;
|
||||
r_cons_bind (&core->print->consbind);
|
||||
|
||||
// We save the old num, in order to restore it after free
|
||||
core->old_num = core->cons->num;
|
||||
core->cons->num = core->num;
|
||||
// We save the old num ad user, in order to restore it after free
|
||||
core->lang = r_lang_new ();
|
||||
core->lang->cmd_str = (char *(*)(void *, const char *))r_core_cmd_str;
|
||||
core->lang->cmdf = (int (*)(void *, const char *, ...))r_core_cmdf;
|
||||
core->cons->cb_editor = (RConsEditorCallback)r_core_editor;
|
||||
core->cons->cb_break = (RConsBreakCallback)r_core_break;
|
||||
core->cons->cb_sleep_begin = (RConsSleepBeginCallback)r_core_sleep_begin;
|
||||
core->cons->cb_sleep_end = (RConsSleepEndCallback)r_core_sleep_end;
|
||||
core->cons->user = (void*)core;
|
||||
r_core_bind_cons (core);
|
||||
core->lang->cb_printf = r_cons_printf;
|
||||
r_lang_define (core->lang, "RCore", "core", core);
|
||||
r_lang_set_user_ptr (core->lang, core);
|
||||
@ -2208,6 +2202,15 @@ R_API bool r_core_init(RCore *core) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API void r_core_bind_cons(RCore *core) {
|
||||
core->cons->num = core->num;
|
||||
core->cons->cb_editor = (RConsEditorCallback)r_core_editor;
|
||||
core->cons->cb_break = (RConsBreakCallback)r_core_break;
|
||||
core->cons->cb_sleep_begin = (RConsSleepBeginCallback)r_core_sleep_begin;
|
||||
core->cons->cb_sleep_end = (RConsSleepEndCallback)r_core_sleep_end;
|
||||
core->cons->user = (void*)core;
|
||||
}
|
||||
|
||||
R_API RCore *r_core_fini(RCore *c) {
|
||||
if (!c) {
|
||||
return NULL;
|
||||
@ -2228,11 +2231,6 @@ R_API RCore *r_core_fini(RCore *c) {
|
||||
free (c->block);
|
||||
r_core_autocomplete_free (c->autocomplete);
|
||||
|
||||
// Check if the old num is saved. If yes, we restore it.
|
||||
if (c->cons && c->old_num) {
|
||||
c->cons->num = c->old_num;
|
||||
c->old_num = NULL;
|
||||
}
|
||||
r_list_free (c->undos);
|
||||
r_num_free (c->num);
|
||||
// TODO: sync or not? sdb_sync (c->sdb);
|
||||
|
@ -183,7 +183,6 @@ typedef struct r_core_t {
|
||||
RCoreFile *file;
|
||||
RList *files;
|
||||
RNum *num;
|
||||
RNum *old_num;
|
||||
RLib *lib;
|
||||
RCmd *rcmd;
|
||||
RCmdDescriptor root_cmd_descriptor;
|
||||
@ -278,6 +277,7 @@ R_API RBin *r_core_get_bin (RCore *core);
|
||||
R_API RConfig *r_core_get_config (RCore *core);
|
||||
R_API RAsmOp *r_core_disassemble (RCore *core, ut64 addr);
|
||||
R_API bool r_core_init(RCore *core);
|
||||
R_API void r_core_bind_cons(RCore *core); // to restore pointers in cons
|
||||
R_API RCore *r_core_new(void);
|
||||
R_API RCore *r_core_free(RCore *core);
|
||||
R_API RCore *r_core_fini(RCore *c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user