Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libr/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -4839,6 +4839,8 @@ R_API int r_core_config_init(RCore *core) {
SETI ("lines.from", 0, "start address for line seek");
SETCB ("lines.to", "$s", &cb_linesto, "end address for line seek");
SETCB ("lines.abs", "false", &cb_linesabs, "enable absolute line numbers");
/* tasks */
SETB ("tasks.isolate", "false", "isolate task cores with separate block buffer");
/* RVC */
{
char *p = r_file_path ("git");
Expand Down
32 changes: 26 additions & 6 deletions libr/core/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,44 @@ static RCore *r_core_clone_for_task(RCore *core);
static int _task_run_threaded(RCoreTaskScheduler *scheduler, RCoreTask *task);
static int _task_run_forked(RCoreTaskScheduler *scheduler, RCoreTask *task);

#define CUSTOMCORE 0
#define CUSTOMCORE 1

static RCore *mycore_new(RCore *core) {
#if CUSTOMCORE
if (!r_config_get_b (core->config, "tasks.isolate")) {
return core;
}
RCore *c = R_NEW (RCore);
memcpy (c, core, sizeof (RCore));
c->cons = r_cons_new ();
// XXX: RConsBind must disappear. its used in bin, fs and search
// TODO: use r_cons_clone instead
if (!c->cons) {
free (c);
return core;
}
if (core->blocksize > 0 && core->block) {
c->block = malloc (core->blocksize);
if (c->block) {
memcpy (c->block, core->block, core->blocksize);
}
} else {
c->block = NULL;
}
return c;
#else
return core;
#endif
}

static void mycore_free(RCore *a) {
static void mycore_free(RCore *c, RCore *orig) {
#if CUSTOMCORE
r_cons_free (a->cons);
if (c && c != orig) {
free (c->block);
r_cons_free (c->cons);
free (c);
}
#else
(void)c;
(void)orig;
#endif
}

Expand Down Expand Up @@ -480,7 +500,7 @@ static RThreadFunctionRet task_run(RCoreTask *task) {
} else {
res_str = r_core_cmd_str (local_core, task->cmd);
}
mycore_free (local_core);
mycore_free (local_core, core);

free (task->res);
task->res = res_str;
Expand Down
Loading