summaryrefslogtreecommitdiff
path: root/src/format/preload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/preload.c')
-rw-r--r--src/format/preload.c134
1 files changed, 128 insertions, 6 deletions
diff --git a/src/format/preload.c b/src/format/preload.c
index 2eec92e..7f7a435 100644
--- a/src/format/preload.c
+++ b/src/format/preload.c
@@ -261,6 +261,30 @@ void g_preload_info_unlock_instructions(GPreloadInfo *info)
void g_preload_info_add_instruction(GPreloadInfo *info, GArchInstruction *instr)
{
+ g_preload_info_lock_instructions(info);
+
+ _g_preload_info_add_instruction(info, instr);
+
+ g_preload_info_unlock_instructions(info);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = instance à mettre à jour. *
+* instr = instruction à venir associer. *
+* *
+* Description : Ajoute une instruction supplémentaire aux préchargements. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void _g_preload_info_add_instruction(GPreloadInfo *info, GArchInstruction *instr)
+{
int cmp_instr_by_addr(const GArchInstruction **a, const GArchInstruction **b)
{
const mrange_t *range_a; /* Emplacement pour l'instr. A */
@@ -273,12 +297,46 @@ void g_preload_info_add_instruction(GPreloadInfo *info, GArchInstruction *instr)
}
- g_preload_info_lock_instructions(info);
-
insert_item_into_flat_array(&info->instructions, &instr, sizeof(GArchInstruction *),
(__compar_fn_t)cmp_instr_by_addr);
- g_preload_info_unlock_instructions(info);
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = instance à mettre à jour. *
+* addr = localisation du commentaire recherché. *
+* *
+* Description : Détermine si une instruction est présente à un point donné. *
+* *
+* Retour : true si une instruction existe à l'emplacement indiqué. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool _g_preload_info_has_instruction_at(GPreloadInfo *info, const vmpa2t *addr)
+{
+ bool result; /* Bilan à retourner */
+ GArchInstruction **ptr; /* Adresse dans le tableau */
+
+ int cmp_instr_by_addr(const vmpa2t *key, const GArchInstruction **i)
+ {
+ const mrange_t *range; /* Emplacement pour l'instr. */
+
+ range = g_arch_instruction_get_range(*i);
+
+ return cmp_vmpa(key, get_mrange_addr(range));
+
+ }
+
+ ptr = find_item_in_flat_array(info->instructions, sizeof(GArchInstruction *),
+ (__compar_fn_t)cmp_instr_by_addr, addr);
+
+ result = (ptr != NULL);
+
+ return result;
}
@@ -457,6 +515,30 @@ void g_preload_info_unlock_comments(GPreloadInfo *info)
void g_preload_info_add_comment(GPreloadInfo *info, GDbComment *comment)
{
+ g_preload_info_lock_comments(info);
+
+ _g_preload_info_add_comment(info, comment);
+
+ g_preload_info_unlock_comments(info);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = instance à mettre à jour. *
+* comment = commentaire à venir associer. *
+* *
+* Description : Ajoute un commentaire supplémentaire aux préchargements. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void _g_preload_info_add_comment(GPreloadInfo *info, GDbComment *comment)
+{
int cmp_comment_by_addr(const GDbComment * const *a, const GDbComment * const *b)
{
const vmpa2t *addr_a; /* Position du commentaire A */
@@ -469,12 +551,52 @@ void g_preload_info_add_comment(GPreloadInfo *info, GDbComment *comment)
}
- g_preload_info_lock_comments(info);
-
insert_item_into_flat_array(&info->comments, &comment, sizeof(GDbComment *),
(__compar_fn_t)cmp_comment_by_addr);
- g_preload_info_unlock_comments(info);
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = instance à mettre à consulter. *
+* addr = localisation du commentaire recherché. *
+* *
+* Description : Recherche un commentaire dans des préchargements. *
+* *
+* Retour : Eventuel commenaire retrouvé ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDbComment *_g_preload_info_find_comment_at(GPreloadInfo *info, const vmpa2t *addr)
+{
+ GDbComment *result; /* Trouvaille à retourner */
+ GDbComment **ptr; /* Adresse dans le tableau */
+
+ int cmp_comment_by_addr(const vmpa2t *key, const GDbComment * const *comment)
+ {
+ const vmpa2t *caddr; /* Position du commentaire */
+
+ caddr = g_db_comment_get_address(*comment);
+
+ return cmp_vmpa(key, caddr);
+
+ }
+
+ ptr = find_item_in_flat_array(info->comments, sizeof(GDbComment *),
+ (__compar_fn_t)cmp_comment_by_addr, addr);
+
+ if (ptr != NULL)
+ {
+ result = *ptr;
+ g_object_ref(G_OBJECT(result));
+ }
+ else
+ result = NULL;
+
+ return result;
}