x86: more simplification on managing MCOperand. this also fixes a bug in handling memory reference instructions
diff --git a/MCInst.c b/MCInst.c
index c459171..3a70af7 100644
--- a/MCInst.c
+++ b/MCInst.c
@@ -80,10 +80,6 @@
// NOTE: this will free @Op argument
int MCInst_addOperand(MCInst *inst, MCOperand *Op)
{
- if (inst->size == ARR_SIZE(inst->Operands))
- // full
- return -1;
-
inst->Operands[inst->size] = *Op;
cs_mem_free(Op);
@@ -92,26 +88,9 @@
return 0;
}
-int MCInst_addOperand0(MCInst *inst, MCOperand *Op)
-{
- if (inst->size == ARR_SIZE(inst->Operands))
- // full
- return -1;
-
- inst->Operands[inst->size] = *Op;
-
- inst->size++;
-
- return 0;
-}
-
// This addOperand2 function doesnt free Op
int MCInst_addOperand2(MCInst *inst, MCOperand *Op)
{
- if (inst->size == ARR_SIZE(inst->Operands))
- // full
- return -1;
-
inst->Operands[inst->size] = *Op;
inst->size++;
@@ -187,6 +166,7 @@
return op;
}
+/*
MCOperand *MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
{
MCOperand *op = &(mcInst->Operands[MCINST_CACHE]);
@@ -196,6 +176,16 @@
return op;
}
+*/
+
+void MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
+{
+ MCOperand *op = &(mcInst->Operands[mcInst->size]);
+ mcInst->size++;
+
+ op->Kind = kRegister;
+ op->RegVal = Reg;
+}
MCOperand *MCOperand_CreateImm(int64_t Val)
{
@@ -207,6 +197,7 @@
return op;
}
+/*
MCOperand *MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
{
MCOperand *op = &(mcInst->Operands[MCINST_CACHE]);
@@ -216,6 +207,16 @@
return op;
}
+*/
+
+void MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
+{
+ MCOperand *op = &(mcInst->Operands[mcInst->size]);
+ mcInst->size++;
+
+ op->Kind = kImmediate;
+ op->ImmVal = Val;
+}
MCOperand *MCOperand_CreateFPImm(double Val)
{