ppc: use MCInst_insert0() instead of MCInst_insert() to avoid malloc/free
This commit is contained in:
parent
d06f3d662b
commit
215e76b223
15
MCInst.c
15
MCInst.c
|
@ -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)
|
||||
{
|
||||
|
|
3
MCInst.h
3
MCInst.h
|
@ -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);
|
||||
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue