diff options
Diffstat (limited to 'src/arch/sharing/instance.c')
-rw-r--r-- | src/arch/sharing/instance.c | 273 |
1 files changed, 0 insertions, 273 deletions
diff --git a/src/arch/sharing/instance.c b/src/arch/sharing/instance.c deleted file mode 100644 index 05081bb..0000000 --- a/src/arch/sharing/instance.c +++ /dev/null @@ -1,273 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instance.c - partage de données d'architecture quelconques - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "instance.h" - - -#include <assert.h> - - -#include "instance-int.h" - - - -/* Procède à l'initialisation de l'interface de partage. */ -static void g_shared_instance_default_init(GSharedInstanceInterface *); - - - -/* Détermine le type d'une interface pour le partage d'instance. */ -G_DEFINE_INTERFACE(GSharedInstance, g_shared_instance, G_TYPE_OBJECT) - - -/****************************************************************************** -* * -* Paramètres : iface = interface GLib à initialiser. * -* * -* Description : Procède à l'initialisation de l'interface de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_shared_instance_default_init(GSharedInstanceInterface *iface) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à initialiser. * -* template = informations à retrouver intégralement. * -* * -* Description : Initialise un nouvel objet partagé avec des informations. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_shared_instance_apply_template(GSharedInstance *instance, const GSharedInstance *template) -{ - bool result; /* Bilan à retourner */ - GSharedInstanceIface *iface; /* Interface utilisée */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - /** - * Le compteur de références des objets GLib doit être incrémenté ici, - * à la différence d'une opération de copie minimaliste. - */ - - result = iface->apply_template(instance, template); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à consulter. * -* template = informations à retrouver intégralement. * -* * -* Description : Réalise une copie minimale d'un contenu partagé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_shared_instance_define_template(const GSharedInstance *instance, GSharedInstance *template) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - /** - * Le compteur de références des objets GLib ne doit pas être incrémenté ici. - * Ce genre de traitement est réservé à la phase d'initialisation. - */ - - iface->define_template(instance, template); - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à modifier. * -* * -* Description : Incrémente le compteur de références d'un élément partagé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_shared_instance_ref(GSharedInstance *instance) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - GShareManager *manager; /* Gestionnaire associé */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - manager = iface->get_manager(instance); - - g_share_manager_get(manager, instance); - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à modifier. * -* * -* Description : Décrémente le compteur de références d'un élément partagé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_shared_instance_unref(GSharedInstance *instance) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - GShareManager *manager; /* Gestionnaire associé */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - manager = iface->get_manager(instance); - - g_share_manager_put(manager, instance); - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à consulter. * -* * -* Description : Fournit la valeur du compteur de partage. * -* * -* Retour : Nombre de partages courant. * -* * -* Remarques : - * -* * -******************************************************************************/ - -unsigned int g_shared_instance_get_references(const GSharedInstance *instance) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - return iface->get_ref(instance); - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à modifier. * -* * -* Description : Incrémente le compteur de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_shared_instance_inc_references(GSharedInstance *instance) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - iface->inc_ref(instance); - -} - - -/****************************************************************************** -* * -* Paramètres : instance = objet partagé à modifier. * -* * -* Description : Décrémente le compteur de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_shared_instance_dec_references(GSharedInstance *instance) -{ - GSharedInstanceIface *iface; /* Interface utilisée */ - - iface = G_SHARED_INSTANCE_GET_IFACE(instance); - - iface->dec_ref(instance); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier objet partagé à consulter. * -* b = second objet partagé à consulter. * -* * -* Description : Compare de façon accélérée un object partagé avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -int g_shared_instance_compare(const GSharedInstance * const *a, const GSharedInstance * const *b) -{ - int result; /* Bilan à faire remonter */ - GSharedInstanceIface *iface; /* Interface utilisée */ - - /** - * Comme les insertions dans les tableaux triés à l'aide de qinsert() - * font passer la clef en premier argument et que celle ci n'est pas un - * objet valide, on inverse les arguments, puis on inverse le résultat obtenu. - */ - - iface = G_SHARED_INSTANCE_GET_IFACE(*b); - - result = iface->compare(b, a) * -1; - - return result; - -} |