diff options
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 1d1ccaf..8e9d3d3 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -607,15 +607,11 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand * count = _g_arch_instruction_count_operands(instr); - for (i = 0; i < count; i++) + for (i = 0; i < count && !result; i++) { op = _g_arch_instruction_get_operand(instr, i); - if (op == old) - { - result = true; - break; - } + result = (op == old); g_object_unref(G_OBJECT(op)); @@ -623,7 +619,7 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand * if (result) { - rpl_item_in_flat_array(instr->operands, i, &new, sizeof(GArchOperand *)); + rpl_item_in_flat_array(instr->operands, i - 1, &new, sizeof(GArchOperand *)); g_object_unref(G_OBJECT(old)); @@ -654,24 +650,23 @@ bool _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *t size_t i; /* Boucle de parcours */ GArchOperand *op; /* Opérande à manipuler */ + result = false; + count = _g_arch_instruction_count_operands(instr); - for (i = 0; i < count; i++) + for (i = 0; i < count && !result; i++) { op = _g_arch_instruction_get_operand(instr, i); - if (op == target) - break; + result = (op == target); g_object_unref(G_OBJECT(op)); } - result = (i < count); - if (result) { - rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *)); + rem_item_from_flat_array(&instr->operands, i - 1, sizeof(GArchOperand *)); g_object_unref(G_OBJECT(target)); |