Avoid reading when it is not necessary in pDj

This commit is contained in:
pancake 2014-12-19 16:57:18 +01:00
parent 1cca39e3f6
commit d6d7a40f4f

View File

@ -11,13 +11,18 @@ static void set_asm_configs(RCore *core, char *arch, ut32 bits, int segoff){
static void cmd_pDj (RCore *core, const char *arg) {
int bsize = r_num_math (core->num, arg);
ut8 *buf = malloc (bsize);
if (buf) {
r_io_read_at (core->io, core->offset, buf, bsize);
r_core_print_disasm_json (core, core->offset, buf, bsize, 0);
free (buf);
} else eprintf ("cannot allocate %d bytes\n", bsize);
//r_core_print_disasm_json (core, core->offset, core->block, bsize, 0);
if (bsize <= core->blocksize) {
r_core_print_disasm_json (core, core->offset, core->block,
bsize, 0);
} else {
ut8 *buf = malloc (bsize);
if (buf) {
r_io_read_at (core->io, core->offset, buf, bsize);
r_core_print_disasm_json (core, core->offset, buf,
bsize, 0);
free (buf);
} else eprintf ("cannot allocate %d bytes\n", bsize);
}
r_cons_newline ();
}