diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-05-21 16:48:11 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-05-21 16:48:11 (GMT) |
commit | acd355c4c5ae25fb9cac64b8dc17407a2bcc979b (patch) | |
tree | d5b43201049116cd9734ff554e61ed8a7e0084cc /src/arch/instruction.c | |
parent | 4691a434a34a19317156a761967f719e408b73bb (diff) |
Refined the whole share system for operands.
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index dd5b019..8f2f262 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -191,6 +191,26 @@ static void g_arch_instruction_generator_interface_init(GLineGeneratorInterface static void g_arch_instruction_dispose(GArchInstruction *instr) { + size_t count; /* Nombre d'opérandes en place */ + size_t i; /* Boucle de parcours */ + GArchOperand *op; /* Opérande à manipuler */ + + g_arch_instruction_lock_operands(instr); + + count = _g_arch_instruction_count_operands(instr); + + for (i = 0; i < count; i++) + { + op = _g_arch_instruction_get_operand(instr, 0); + + rem_item_from_flat_array(&instr->operands, 0, sizeof(GArchOperand *)); + + g_shared_instance_unref(G_SHARED_INSTANCE(op)); + + } + + g_arch_instruction_unlock_operands(instr); + G_OBJECT_CLASS(g_arch_instruction_parent_class)->dispose(G_OBJECT(instr)); } @@ -619,7 +639,7 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand * { rpl_item_in_flat_array(instr->operands, i, &new, sizeof(GArchOperand *)); - //g_object_unref(G_OBJECT(old)); + g_shared_instance_unref(G_SHARED_INSTANCE(old)); } @@ -660,7 +680,7 @@ void _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *t rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *)); - g_object_unref(G_OBJECT(target)); + g_shared_instance_unref(G_SHARED_INSTANCE(target)); } |