summaryrefslogtreecommitdiff
path: root/libdevkit-power
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2008-11-08 15:50:30 +0000
committerRichard Hughes <richard@hughsie.com>2008-11-08 15:50:30 +0000
commite5de05c69a80aaa79d2c9465e03a483cfaf5f0a8 (patch)
treefdc68bdc39150970cc9bcf90f6ea563024b8c0a6 /libdevkit-power
parent67c7fb3cda6746fad3a20516f96809743a0ee57a (diff)
bigfix: fix a problem with egg_obj_list_clear where the last item was not being removed from the list
Diffstat (limited to 'libdevkit-power')
-rw-r--r--libdevkit-power/egg-obj-list.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libdevkit-power/egg-obj-list.c b/libdevkit-power/egg-obj-list.c
index e64115b..d0a255e 100644
--- a/libdevkit-power/egg-obj-list.c
+++ b/libdevkit-power/egg-obj-list.c
@@ -137,8 +137,6 @@ egg_obj_list_set_from_string (EggObjList *list, EggObjListFromStringFunc func)
void
egg_obj_list_clear (EggObjList *list)
{
- guint i;
- gpointer obj;
GPtrArray *array;
EggObjListFreeFunc func_free;
@@ -146,12 +144,11 @@ egg_obj_list_clear (EggObjList *list)
array = list->priv->array;
func_free = list->priv->func_free;
- for (i=0; i<array->len; i++) {
- obj = g_ptr_array_index (array, i);
- if (func_free != NULL)
- func_free (obj);
- g_ptr_array_remove (array, obj);
- }
+
+ if (func_free != NULL)
+ g_ptr_array_foreach (array, (GFunc) func_free, NULL);
+ g_ptr_array_remove_range (array, 0, array->len);
+
list->len = 0;
}