From 16f9d3b943e272112e01f5bc51e922e2ea2ddfb8 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 24 Nov 2014 21:12:48 +0000 Subject: Cleaned operands, using class functions and destructors. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@426 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 14 +++++ src/arch/dalvik/operands/args.c | 60 +++++++++++++++++++- src/arch/dalvik/operands/pool.c | 59 ++++++++++++++++++- src/arch/dalvik/operands/register.c | 58 +++++++++++++++++-- src/arch/dalvik/operands/target.c | 57 ++++++++++++++++++- src/arch/immediate.c | 58 +++++++++++++++++-- src/arch/operand-int.h | 6 +- src/arch/operand.c | 56 +++++++++++++++++- src/arch/operand.h | 4 +- src/arch/raw.c | 3 - src/arch/register.c | 110 ++++++++++++++++++++++++++++++++++-- 11 files changed, 452 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index d29ce85..b029fdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 14-11-24 Cyrille Bagard + * src/arch/dalvik/operands/args.c: + * src/arch/dalvik/operands/pool.c: + * src/arch/dalvik/operands/register.c: + * src/arch/dalvik/operands/target.c: + * src/arch/immediate.c: + * src/arch/operand.c: + * src/arch/operand.h: + * src/arch/operand-int.h: + * src/arch/raw.c: + * src/arch/register.c: + Clean operands, using class functions and destructors. + +14-11-24 Cyrille Bagard + * src/arch/Makefile.am: * src/arch/processor.c: * src/format/elf/helper_x86.c: diff --git a/src/arch/dalvik/operands/args.c b/src/arch/dalvik/operands/args.c index 458a38e..2897698 100644 --- a/src/arch/dalvik/operands/args.c +++ b/src/arch/dalvik/operands/args.c @@ -56,6 +56,12 @@ static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *); /* Initialise une instance de liste d'opérandes Dalvik. */ static void g_dalvik_args_operand_init(GDalvikArgsOperand *); +/* Supprime toutes les références externes. */ +static void g_dalvik_args_operand_dispose(GDalvikArgsOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_dalvik_args_operand_finalize(GDalvikArgsOperand *); + /* Traduit un opérande en version humainement lisible. */ static void g_dalvik_args_operand_print(const GDalvikArgsOperand *, GBufferLine *, AsmSyntax); @@ -79,6 +85,16 @@ G_DEFINE_TYPE(GDalvikArgsOperand, g_dalvik_args_operand, G_TYPE_ARCH_OPERAND); static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_args_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_dalvik_args_operand_finalize; + + operand->print = (operand_print_fc)g_dalvik_args_operand_print; } @@ -97,11 +113,49 @@ static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass) static void g_dalvik_args_operand_init(GDalvikArgsOperand *operand) { - GArchOperand *parent; /* Instance parente */ - parent = G_ARCH_OPERAND(operand); +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - parent->print = (operand_print_fc)g_dalvik_args_operand_print; +static void g_dalvik_args_operand_dispose(GDalvikArgsOperand *operand) +{ + size_t i; + + for (i = 0; i < operand->count; i++) + g_object_unref(G_OBJECT(operand->args[i])); + + G_OBJECT_CLASS(g_dalvik_args_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_args_operand_finalize(GDalvikArgsOperand *operand) +{ + G_OBJECT_CLASS(g_dalvik_args_operand_parent_class)->finalize(G_OBJECT(operand)); } diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c index 2c1f653..a1fde2e 100644 --- a/src/arch/dalvik/operands/pool.c +++ b/src/arch/dalvik/operands/pool.c @@ -62,6 +62,12 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *); /* Initialise une instance d'opérande de constante Dalvik. */ static void g_dalvik_pool_operand_init(GDalvikPoolOperand *); +/* Supprime toutes les références externes. */ +static void g_dalvik_pool_operand_dispose(GDalvikPoolOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *); + /* Traduit un opérande en version humainement lisible. */ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *, GBufferLine *, AsmSyntax); @@ -85,6 +91,16 @@ G_DEFINE_TYPE(GDalvikPoolOperand, g_dalvik_pool_operand, G_TYPE_ARCH_OPERAND); static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_pool_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_dalvik_pool_operand_finalize; + + operand->print = (operand_print_fc)g_dalvik_pool_operand_print; } @@ -103,11 +119,46 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass) static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand) { - GArchOperand *parent; /* Instance parente */ - parent = G_ARCH_OPERAND(operand); +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - parent->print = (operand_print_fc)g_dalvik_pool_operand_print; +static void g_dalvik_pool_operand_dispose(GDalvikPoolOperand *operand) +{ + g_object_unref(G_OBJECT(operand->format)); + + G_OBJECT_CLASS(g_dalvik_pool_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *operand) +{ + G_OBJECT_CLASS(g_dalvik_pool_operand_parent_class)->finalize(G_OBJECT(operand)); } @@ -155,6 +206,8 @@ GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType result = g_object_new(G_TYPE_DALVIK_POOL_OPERAND, NULL); + g_object_ref(G_OBJECT(format)); + result->format = format; result->type = type; result->index = (size == MDS_8_BITS ? index8 : index16); diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c index 00d5699..2ae9224 100644 --- a/src/arch/dalvik/operands/register.c +++ b/src/arch/dalvik/operands/register.c @@ -53,6 +53,12 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *); /* Initialise une instance d'opérande de registre Dalvik. */ static void g_dalvik_register_operand_init(GDalvikRegisterOperand *); +/* Supprime toutes les références externes. */ +static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *); + /* Compare un opérande avec un autre. */ static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); @@ -79,6 +85,17 @@ G_DEFINE_TYPE(GDalvikRegisterOperand, g_dalvik_register_operand, G_TYPE_ARCH_OPE static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_register_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_dalvik_register_operand_finalize; + + operand->compare = (operand_compare_fc)g_dalvik_register_operand_compare; + operand->print = (operand_print_fc)g_dalvik_register_operand_print; } @@ -97,14 +114,45 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) { - GArchOperand *parent; /* Instance parente */ + operand->is_written = false; - parent = G_ARCH_OPERAND(operand); +} - parent->compare = (operand_compare_fc)g_dalvik_register_operand_compare; - parent->print = (operand_print_fc)g_dalvik_register_operand_print; - operand->is_written = false; +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *operand) +{ + G_OBJECT_CLASS(g_dalvik_register_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand) +{ + G_OBJECT_CLASS(g_dalvik_register_operand_parent_class)->finalize(G_OBJECT(operand)); } diff --git a/src/arch/dalvik/operands/target.c b/src/arch/dalvik/operands/target.c index f53bb7b..147aaae 100644 --- a/src/arch/dalvik/operands/target.c +++ b/src/arch/dalvik/operands/target.c @@ -52,6 +52,12 @@ static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *); /* Initialise une instance d'opérande de ciblage de code Dalvik. */ static void g_dalvik_target_operand_init(GDalvikTargetOperand *); +/* Supprime toutes les références externes. */ +static void g_dalvik_target_operand_dispose(GDalvikTargetOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_dalvik_target_operand_finalize(GDalvikTargetOperand *); + /* Traduit un opérande en version humainement lisible. */ static void g_dalvik_target_operand_print(const GDalvikTargetOperand *, GBufferLine *, AsmSyntax); @@ -75,6 +81,16 @@ G_DEFINE_TYPE(GDalvikTargetOperand, g_dalvik_target_operand, G_TYPE_ARCH_OPERAND static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_target_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_dalvik_target_operand_finalize; + + operand->print = (operand_print_fc)g_dalvik_target_operand_print; } @@ -93,11 +109,46 @@ static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *klass) static void g_dalvik_target_operand_init(GDalvikTargetOperand *operand) { - GArchOperand *parent; /* Instance parente */ - parent = G_ARCH_OPERAND(operand); +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_target_operand_dispose(GDalvikTargetOperand *operand) +{ + g_object_unref(G_OBJECT(operand->immediate)); + + G_OBJECT_CLASS(g_dalvik_target_operand_parent_class)->dispose(G_OBJECT(operand)); + +} - parent->print = (operand_print_fc)g_dalvik_target_operand_print; + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_target_operand_finalize(GDalvikTargetOperand *operand) +{ + G_OBJECT_CLASS(g_dalvik_target_operand_parent_class)->finalize(G_OBJECT(operand)); } diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 88a0f4b..574fc3d 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -88,6 +88,12 @@ static void g_imm_operand_class_init(GImmOperandClass *); /* Initialise la classe des lignes de descriptions initiales. */ static void g_imm_operand_init(GImmOperand *); +/* Supprime toutes les références externes. */ +static void g_imm_operand_dispose(GImmOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_imm_operand_finalize(GImmOperand *); + /* Construit la chaîne de caractères correspondant à l'opérande. */ static size_t g_imm_operand_to_string(const GImmOperand *, AsmSyntax, char [VMPA_MAX_SIZE]); @@ -115,6 +121,16 @@ G_DEFINE_TYPE(GImmOperand, g_imm_operand, G_TYPE_ARCH_OPERAND); static void g_imm_operand_class_init(GImmOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_imm_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_imm_operand_finalize; + + operand->print = (operand_print_fc)g_imm_operand_print; } @@ -133,14 +149,46 @@ static void g_imm_operand_class_init(GImmOperandClass *klass) static void g_imm_operand_init(GImmOperand *operand) { - GArchOperand *arch; /* Instance parente */ + operand->zpad = false; + operand->display = IOD_HEX; - arch = G_ARCH_OPERAND(operand); +} - arch->print = (operand_print_fc)g_imm_operand_print; - operand->zpad = false; - operand->display = IOD_HEX; +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_imm_operand_dispose(GImmOperand *operand) +{ + G_OBJECT_CLASS(g_imm_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_imm_operand_finalize(GImmOperand *operand) +{ + G_OBJECT_CLASS(g_imm_operand_parent_class)->finalize(G_OBJECT(operand)); } diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index 603a39d..697a896 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -41,9 +41,6 @@ struct _GArchOperand { GObject parent; /* A laisser en premier */ - operand_compare_fc compare; /* Comparaison d'opérandes */ - operand_print_fc print; /* Texte humain équivalent */ - char *alt_text; /* Eventuel texte alternatif */ size_t alt_len; /* Taille de ce texte */ RenderingTagType alt_tag; /* Type de rendu */ @@ -56,6 +53,9 @@ struct _GArchOperandClass { GObjectClass parent; /* A laisser en premier */ + operand_compare_fc compare; /* Comparaison d'opérandes */ + operand_print_fc print; /* Texte humain équivalent */ + }; diff --git a/src/arch/operand.c b/src/arch/operand.c index ede3cdd..5b36e13 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -38,6 +38,12 @@ static void g_arch_operand_class_init(GArchOperandClass *); /* Initialise une instance d'opérande d'architecture. */ static void g_arch_operand_init(GArchOperand *); +/* Supprime toutes les références externes. */ +static void g_arch_operand_dispose(GArchOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arch_operand_finalize(GArchOperand *); + /* Indique le type défini pour un opérande d'architecture. */ @@ -59,6 +65,12 @@ G_DEFINE_TYPE(GArchOperand, g_arch_operand, G_TYPE_OBJECT); static void g_arch_operand_class_init(GArchOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_arch_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_arch_operand_finalize; } @@ -83,6 +95,46 @@ static void g_arch_operand_init(GArchOperand *operand) /****************************************************************************** * * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_operand_dispose(GArchOperand *operand) +{ + G_OBJECT_CLASS(g_arch_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_operand_finalize(GArchOperand *operand) +{ + g_arch_operand_set_alt_text(operand, NULL, RTT_COUNT); + + G_OBJECT_CLASS(g_arch_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * * Paramètres : a = premier opérande à consulter. * * b = second opérande à consulter. * * * @@ -101,7 +153,7 @@ bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b) result = (G_OBJECT_TYPE(G_OBJECT(a)) == G_OBJECT_TYPE(G_OBJECT(b))); if (result) - result = a->compare(a, b); + result = G_ARCH_OPERAND_GET_CLASS(a)->compare(a, b); return result; @@ -166,6 +218,6 @@ void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyn operand->alt_tag); else - operand->print(operand, line, syntax); + G_ARCH_OPERAND_GET_CLASS(operand)->print(operand, line, syntax); } diff --git a/src/arch/operand.h b/src/arch/operand.h index f4a941e..724b634 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -35,7 +35,9 @@ #define G_TYPE_ARCH_OPERAND g_arch_operand_get_type() #define G_ARCH_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arch_operand_get_type(), GArchOperand)) #define G_IS_ARCH_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arch_operand_get_type())) -#define G_ARCH_OPERAND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_arch_operand_get_type(), GArchOperandIface)) +#define G_ARCH_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARCH_OPERAND, GArchOperandClass)) +#define G_IS_ARCH_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARCH_OPERAND)) +#define G_ARCH_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARCH_OPERAND, GArchOperandClass)) /* Définition générique d'un opérande d'architecture (instance) */ diff --git a/src/arch/raw.c b/src/arch/raw.c index e127f91..164086a 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -122,9 +122,6 @@ static void g_raw_instruction_class_init(GRawInstructionClass *klass) static void g_raw_instruction_init(GRawInstruction *instr) { - GArchInstruction *parent; /* Instance parente */ - - parent = G_ARCH_INSTRUCTION(instr); } diff --git a/src/arch/register.c b/src/arch/register.c index 706fcd4..3094e0f 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -37,6 +37,12 @@ static void g_arch_register_class_init(GArchRegisterClass *); /* Initialise une instance de registre. */ static void g_arch_register_init(GArchRegister *); +/* Supprime toutes les références externes. */ +static void g_arch_register_dispose(GArchRegister *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arch_register_finalize(GArchRegister *); + /* ------------------------- REGISTRE SOUS FORME D'OPERANDE ------------------------- */ @@ -48,6 +54,12 @@ static void g_register_operand_class_init(GRegisterOperandClass *); /* Initialise une instance d'opérande de registre. */ static void g_register_operand_init(GRegisterOperand *); +/* Supprime toutes les références externes. */ +static void g_register_operand_dispose(GRegisterOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_register_operand_finalize(GRegisterOperand *); + /* Compare un opérande avec un autre. */ static bool g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *); @@ -79,6 +91,12 @@ G_DEFINE_TYPE(GArchRegister, g_arch_register, G_TYPE_OBJECT); static void g_arch_register_class_init(GArchRegisterClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_arch_register_dispose; + object->finalize = (GObjectFinalizeFunc)g_arch_register_finalize; } @@ -103,6 +121,44 @@ static void g_arch_register_init(GArchRegister *reg) /****************************************************************************** * * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_register_dispose(GArchRegister *reg) +{ + G_OBJECT_CLASS(g_arch_register_parent_class)->dispose(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_register_finalize(GArchRegister *reg) +{ + G_OBJECT_CLASS(g_arch_register_parent_class)->finalize(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * * Paramètres : reg = opérande à consulter pour le calcul. * * * * Description : Produit une empreinte à partir d'un registre. * @@ -261,6 +317,17 @@ G_DEFINE_TYPE(GRegisterOperand, g_register_operand, G_TYPE_ARCH_OPERAND); static void g_register_operand_class_init(GRegisterOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_register_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_register_operand_finalize; + + operand->compare = (operand_compare_fc)g_register_operand_compare; + operand->print = (operand_print_fc)g_register_operand_print; } @@ -279,14 +346,47 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass) static void g_register_operand_init(GRegisterOperand *operand) { - GArchOperand *parent; /* Instance parente */ + operand->is_written = false; - parent = G_ARCH_OPERAND(operand); +} - parent->compare = (operand_compare_fc)g_register_operand_compare; - parent->print = (operand_print_fc)g_register_operand_print; - operand->is_written = false; +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_register_operand_dispose(GRegisterOperand *operand) +{ + g_object_unref(G_OBJECT(operand->reg)); + + G_OBJECT_CLASS(g_register_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_register_operand_finalize(GRegisterOperand *operand) +{ + G_OBJECT_CLASS(g_register_operand_parent_class)->finalize(G_OBJECT(operand)); } -- cgit v0.11.2-87-g4458