ppc: use MCInst_insert0() instead of MCInst_insert() to avoid malloc/free

This commit is contained in:
Nguyen Anh Quynh 2014-06-16 14:47:43 +08:00
parent d06f3d662b
commit 215e76b223
3 changed files with 2 additions and 20 deletions

View File

@ -27,21 +27,6 @@ void MCInst_clear(MCInst *inst)
inst->size = 0;
}
// NOTE: this will free @Op argument
void MCInst_insert(MCInst *inst, int index, MCOperand *Op)
{
int i;
for(i = inst->size; i > index; i--)
//memcpy(&(inst->Operands[i]), &(inst->Operands[i-1]), sizeof(MCOperand));
inst->Operands[i] = inst->Operands[i-1];
inst->Operands[index] = *Op;
inst->size++;
cs_mem_free(Op);
}
// do not free @Op
void MCInst_insert0(MCInst *inst, int index, MCOperand *Op)
{

View File

@ -115,9 +115,6 @@ void MCInst_Init(cs_struct *handle, MCInst *inst);
void MCInst_clear(MCInst *inst);
// free operand after inserting
void MCInst_insert(MCInst *inst, int index, MCOperand *Op);
// do not free operand after inserting
void MCInst_insert0(MCInst *inst, int index, MCOperand *Op);

View File

@ -224,7 +224,7 @@ static DecodeStatus decodeMemRIOperands(MCInst *Inst, uint64_t Imm,
case PPC_STWU:
case PPC_STFSU:
case PPC_STFDU:
MCInst_insert(Inst, 0, MCOperand_CreateReg(GP0Regs[Base]));
MCInst_insert0(Inst, 0, MCOperand_CreateReg1(Inst, GP0Regs[Base]));
break;
}
@ -248,7 +248,7 @@ static DecodeStatus decodeMemRIXOperands(MCInst *Inst, uint64_t Imm,
// Add the tied output operand.
MCOperand_CreateReg0(Inst, GP0Regs[Base]);
else if (MCInst_getOpcode(Inst) == PPC_STDU)
MCInst_insert(Inst, 0, MCOperand_CreateReg(GP0Regs[Base]));
MCInst_insert0(Inst, 0, MCOperand_CreateReg1(Inst, GP0Regs[Base]));
MCOperand_CreateImm0(Inst, SignExtend64(Disp << 2, 16));
MCOperand_CreateReg0(Inst, GP0Regs[Base]);