diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-02-20 08:11:17 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-02-20 08:11:17 (GMT) |
commit | 26f93f593542cc550107744e92f95e9516e7435e (patch) | |
tree | 058cf883324274965356beb42398c387c0e49217 /src/analysis/scan/matches.c | |
parent | 30e56f25772247d76c7775d32ccd5b5a0661d3bf (diff) |
Share GObject instances between scan contexts and matches.
Diffstat (limited to 'src/analysis/scan/matches.c')
-rw-r--r-- | src/analysis/scan/matches.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/analysis/scan/matches.c b/src/analysis/scan/matches.c index 3dc15f9..d83114c 100644 --- a/src/analysis/scan/matches.c +++ b/src/analysis/scan/matches.c @@ -84,6 +84,7 @@ static void g_scan_matches_class_init(GScanMatchesClass *klass) static void g_scan_matches_init(GScanMatches *matches) { + matches->context = NULL; matches->source = NULL; } @@ -103,7 +104,10 @@ static void g_scan_matches_init(GScanMatches *matches) static void g_scan_matches_dispose(GScanMatches *matches) { - g_clear_object(&matches->source); + /** + * Contexte et source sont des instances partagées. Leur propriété n'est + * donc pas à modifier avec un appel à g_clear_object() ici. + */ G_OBJECT_CLASS(g_scan_matches_parent_class)->dispose(G_OBJECT(matches)); @@ -131,6 +135,53 @@ static void g_scan_matches_finalize(GScanMatches *matches) /****************************************************************************** * * +* Paramètres : matches = instance dont l'initialisation est à compléter. * +* context = contexte associé au scan courant. * +* source = lien vers le motif recherché d'origine. * +* * +* Description : Associe des éléments de contexte à des correspondances. * +* * +* Retour : - * +* * +* Remarques : Aucun transfert de propriété n'a lieu ici ! * +* * +******************************************************************************/ + +void g_scan_matches_attach(GScanMatches *matches, const GScanContext *context, const GSearchPattern *source) +{ + matches->context = context; + matches->source = source; + +} + + +/****************************************************************************** +* * +* Paramètres : matches = informations de correspondances à consulter. * +* * +* Description : Fournit le contexte du scan associé aux correspondances. * +* * +* Retour : Contexte de scan courant. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GScanContext *g_scan_bytes_matches_get_context(const GScanMatches *matches) +{ + GScanContext *result; /* Instance à retourner */ + + result = (GScanContext *)matches->context; + + g_object_ref(G_OBJECT(result)); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : matches = définition de correspondance à consulter. * * * * Description : Indique la source du motif d'origine recherché. * @@ -145,7 +196,7 @@ GSearchPattern *g_scan_matches_get_source(const GScanMatches *matches) { GSearchPattern *result; /* Source à retourner */ - result = matches->source; + result = (GSearchPattern *)matches->source; g_object_ref(G_OBJECT(result)); |