MCInst_Init() is arch-independent

This commit is contained in:
Nguyen Anh Quynh
2014-06-16 15:54:32 +08:00
parent 370b7d7d4e
commit 495295ecd4
4 changed files with 9 additions and 13 deletions

View File

@ -10,16 +10,12 @@
#define MCINST_CACHE (ARR_SIZE(mcInst->Operands) - 1)
void MCInst_Init(cs_struct *handle, MCInst *inst)
void MCInst_Init(MCInst *inst)
{
switch(handle->arch) {
default:
memset(inst, 0, sizeof(*inst));
break;
case CS_ARCH_X86:
inst->size = 0;
break;
}
inst->OpcodePub = 0;
inst->size = 0;
return;
}
void MCInst_clear(MCInst *inst)

View File

@ -92,9 +92,9 @@ MCOperand *MCOperand_CreateImm1(MCInst *inst, int64_t Val);
struct MCInst {
unsigned Opcode;
MCOperand Operands[34];
unsigned OpcodePub;
unsigned size; // number of operands
cs_insn *flat_insn; // insn to be exposed to public
unsigned OpcodePub;
uint64_t address; // address of this insn
cs_struct *csh; // save the main csh
uint8_t x86_imm_size; // save immediate size to print immediate properly
@ -105,7 +105,7 @@ struct MCInst {
uint8_t x86_prefix[4];
};
void MCInst_Init(cs_struct *handle, MCInst *inst);
void MCInst_Init(MCInst *inst);
void MCInst_clear(MCInst *inst);

View File

@ -538,7 +538,7 @@ void ARM_printInst(MCInst *MI, SStream *O, void *Info)
if (MCRegisterClass_contains(MRC, Reg)) {
MCInst NewMI;
MCInst_Init(MI->csh, &NewMI);
MCInst_Init(&NewMI);
MCInst_setOpcode(&NewMI, Opcode);
if (isStore)

2
cs.c
View File

@ -449,7 +449,7 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset,
insn_cache = total;
while (size > 0) {
MCInst_Init(handle, &mci);
MCInst_Init(&mci);
mci.csh = handle;
// relative branches need to know the address & size of current insn