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.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/src/format/preload.c b/src/format/preload.c
index 145dfd9..750a67c 100644
--- a/src/format/preload.c
+++ b/src/format/preload.c
@@ -110,6 +110,12 @@ static void g_preload_info_dispose(GPreloadInfo *info)
g_preload_info_lock_instructions(info);
+ while (_g_preload_info_count_instructions(info) > 0)
+ {
+ instr = _g_preload_info_grab_instruction(info, 0);
+ g_object_unref(G_OBJECT(instr));
+ }
+
_g_preload_info_drain_instructions(info);
g_preload_info_unlock_instructions(info);
@@ -118,14 +124,12 @@ static void g_preload_info_dispose(GPreloadInfo *info)
while (_g_preload_info_count_comments(info) > 0)
{
- comment = _g_preload_info_get_comment(info, 0);
-
- rem_item_from_flat_array(&info->comments, 0, sizeof(GDbComment *));
-
+ comment = _g_preload_info_grab_comment(info, 0);
g_object_unref(G_OBJECT(comment));
-
}
+ _g_preload_info_drain_comments(info);
+
g_preload_info_unlock_comments(info);
G_OBJECT_CLASS(g_preload_info_parent_class)->dispose(G_OBJECT(info));
@@ -286,7 +290,7 @@ size_t _g_preload_info_count_instructions(const GPreloadInfo *info)
* *
******************************************************************************/
-GArchInstruction *_g_preload_info_get_instruction(const GPreloadInfo *info, size_t index)
+GArchInstruction *_g_preload_info_grab_instruction(const GPreloadInfo *info, size_t index)
{
GArchInstruction *result; /* Opérande à retourner */
GArchInstruction **ptr; /* Adresse dans le tableau */
@@ -295,7 +299,14 @@ GArchInstruction *_g_preload_info_get_instruction(const GPreloadInfo *info, size
result = *ptr;
- g_object_ref(G_OBJECT(result));
+ /**
+ * La propriétée de l'élément est transmise à l'appelant.
+ *
+ * Ainsi, pour vider une liste via _g_preload_info_drain_instructions(),
+ * il suffit juste de libérer la mémoire occupée pour le stockage sans
+ * se préoccuper des références contenues ; le gain de temps est important
+ * puisqu'on évite là un parcours et des déplacements.
+ */
return result;
@@ -354,17 +365,12 @@ GArchInstruction *g_preload_info_pop_instruction(GPreloadInfo *info)
void _g_preload_info_drain_instructions(GPreloadInfo *info)
{
- GArchInstruction *instr; /* Instruction à libérer */
-
- while (_g_preload_info_count_instructions(info) > 0)
- {
- instr = _g_preload_info_get_instruction(info, 0);
-
- rem_item_from_flat_array(&info->instructions, 0, sizeof(GArchInstruction *));
-
- g_object_unref(G_OBJECT(instr));
+ /**
+ * A utiliser en conjonction avec _g_preload_info_grab_instruction()
+ * uniquement.
+ */
- }
+ reset_flat_array(&info->instructions);
}
@@ -480,7 +486,7 @@ size_t _g_preload_info_count_comments(const GPreloadInfo *info)
* *
******************************************************************************/
-GDbComment *_g_preload_info_get_comment(const GPreloadInfo *info, size_t index)
+GDbComment *_g_preload_info_grab_comment(const GPreloadInfo *info, size_t index)
{
GDbComment *result; /* Opérande à retourner */
GDbComment **ptr; /* Adresse dans le tableau */
@@ -489,7 +495,14 @@ GDbComment *_g_preload_info_get_comment(const GPreloadInfo *info, size_t index)
result = *ptr;
- g_object_ref(G_OBJECT(result));
+ /**
+ * La propriétée de l'élément est transmise à l'appelant.
+ *
+ * Ainsi, pour vider une liste via _g_preload_info_drain_comments(),
+ * il suffit juste de libérer la mémoire occupée pour le stockage sans
+ * se préoccuper des références contenues ; le gain de temps est important
+ * puisqu'on évite là un parcours et des déplacements.
+ */
return result;
@@ -500,35 +513,21 @@ GDbComment *_g_preload_info_get_comment(const GPreloadInfo *info, size_t index)
* *
* Paramètres : info = instance à manipuler. *
* *
-* Description : Dépile un commentaire présent dans les préchargements. *
+* Description : Retire des préchargements tous les commentaires. *
* *
-* Retour : Commentaire retiré ou NULL si aucune. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GDbComment *g_preload_info_pop_comment(GPreloadInfo *info)
+void _g_preload_info_drain_comments(GPreloadInfo *info)
{
- GDbComment *result; /* Instruction à retourner */
- GDbComment **ptr; /* Adresse dans le tableau */
-
- g_preload_info_lock_comments(info);
+ /**
+ * A utiliser en conjonction avec _g_preload_info_grab_comment()
+ * uniquement.
+ */
- if (_g_preload_info_count_comments(info) == 0)
- result = NULL;
-
- else
- {
- ptr = get_flat_array_item(info->comments, 0, sizeof(GDbComment *));
- result = *ptr;
-
- rem_item_from_flat_array(&info->comments, 0, sizeof(GDbComment *));
-
- }
-
- g_preload_info_unlock_comments(info);
-
- return result;
+ reset_flat_array(&info->comments);
}