cleanup : move the initialization of m68k_info

Simplify the code by moving the initialization of printer_info (m68k_info)
at the right place, in the module.init() function.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
This commit is contained in:
Nicolas PLANEL 2015-10-08 15:42:39 +11:00
parent b9f66d63c9
commit d1b5c3f384
2 changed files with 9 additions and 13 deletions

View File

@ -3868,18 +3868,7 @@ bool M68K_getInstruction(csh ud, const uint8_t* code, size_t code_len, MCInst* i
int s;
int cpu_type = M68K_CPU_TYPE_68000;
cs_struct* handle = instr->csh;
m68k_info *info;
if (handle->printer_info == NULL) {
info = cs_mem_malloc(sizeof(m68k_info));
if (!info) {
handle->errnum = CS_ERR_MEM;
return false;
}
handle->printer_info = info;
} else {
info = (m68k_info *)handle->printer_info;
}
m68k_info *info = (m68k_info *)handle->printer_info;
info->code = code;
info->baseAddress = address;

View File

@ -10,8 +10,15 @@
static cs_err init(cs_struct *ud)
{
m68k_info *info;
info = cs_mem_malloc(sizeof(m68k_info));
if (!info) {
return CS_ERR_MEM;
}
ud->printer = M68K_printInst;
ud->printer_info = NULL;
ud->printer_info = info;
ud->getinsn_info = NULL;
ud->disasm = M68K_getInstruction;
ud->skipdata_size = 2;