summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-10-28 19:40:19 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-10-28 19:40:19 (GMT)
commit0f0cb560006c0ef5eb690f89c4ce720936c9d6f6 (patch)
tree09a09248b4da91cbebae8609249d02f3fbef1ef3 /src
parent3e6c0fb01710f61e8dc9383de6be4db1188b3ee6 (diff)
Stored instruction hooks in the data section rather than in the heap.
Diffstat (limited to 'src')
-rw-r--r--src/arch/instruction-int.h2
-rw-r--r--src/arch/instruction.c8
-rw-r--r--src/arch/instruction.h2
3 files changed, 5 insertions, 7 deletions
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index dca63e7..8eb6b68 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -63,7 +63,7 @@ struct _GArchInstruction
phys_t max_displayed_len; /* Quantité de code affichée */
ArchInstrFlag flags; /* Informations complémentaires*/
- instr_hook_fc hooks[IPH_COUNT]; /* Traitements complémentaires */
+ const instr_hook_fc *hooks; /* Traitements complémentaires */
mrange_t range; /* Emplacement en mémoire */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 8264f5b..4c0fdb9 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -281,11 +281,9 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr)
* *
******************************************************************************/
-void g_arch_instruction_set_hook(GArchInstruction *instr, InstrProcessHook type, instr_hook_fc hook)
+void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc hooks[IPH_COUNT])
{
- assert(type < IPH_COUNT);
-
- instr->hooks[type] = hook;
+ instr->hooks = hooks;
}
@@ -310,7 +308,7 @@ void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type
{
assert(type < IPH_COUNT);
- if (instr->hooks[type] != NULL)
+ if (instr->hooks != NULL && instr->hooks[type] != NULL)
instr->hooks[type](instr, proc, context, format);
}
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index e902849..93dfa52 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -117,7 +117,7 @@ typedef enum _InstrProcessHook
typedef void (* instr_hook_fc) (GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);
/* Définit un traitement complémentare au désassemblage. */
-void g_arch_instruction_set_hook(GArchInstruction *, InstrProcessHook, instr_hook_fc);
+void g_arch_instruction_set_hooks(GArchInstruction *, const instr_hook_fc [IPH_COUNT]);
/* Complète un désassemblage accompli pour une instruction. */
void g_arch_instruction_call_hook(GArchInstruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GBinFormat *);