summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2011-12-12 16:14:57 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2012-01-06 15:00:39 -0500
commit4c9424e18d71237f438a99bc5f2d45ae7de60b78 (patch)
treeb442bfdc108ca8019ed423e6f22fe30ec3e7afa8
parent7c38c1ae2240d58fa3709ee92509562358fbe852 (diff)
downloadgobject-introspection-4c9424e18d71237f438a99bc5f2d45ae7de60b78.tar.gz
repository: Squash memory leak in _get_func and fix up style
-rw-r--r--girepository/giobjectinfo.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c
index fbf5d8ab..4aca8bd4 100644
--- a/girepository/giobjectinfo.c
+++ b/girepository/giobjectinfo.c
@@ -756,28 +756,30 @@ _get_func(GIObjectInfo *info,
const char* symbol;
GSList *parents = NULL, *l;
GIObjectInfo *parent_info;
+ gpointer func = NULL;
parent_info = info;
- while (parent_info != NULL) {
- parents = g_slist_prepend(parents, parent_info);
- parent_info = g_object_info_get_parent(parent_info);
- }
-
- for (l = parents; l; l = l->next) {
- GIObjectInfoRefFunction func;
- parent_info = l->data;
- symbol = getter(parent_info);
- if (symbol == NULL)
- continue;
- if (g_typelib_symbol (((GIRealInfo *)parent_info)->typelib, symbol, (void**) &func)) {
- g_slist_free(parents);
- return func;
+ while (parent_info != NULL)
+ {
+ parents = g_slist_prepend (parents, parent_info);
+ parent_info = g_object_info_get_parent (parent_info);
}
- }
- g_slist_free(parents);
- return NULL;
+ for (l = parents; l; l = l->next)
+ {
+ GIObjectInfoRefFunction func;
+ parent_info = l->data;
+ symbol = getter (parent_info);
+ if (symbol == NULL)
+ continue;
+
+ g_typelib_symbol (((GIRealInfo *)parent_info)->typelib, symbol, (gpointer*) &func);
+ if (func)
+ break;
+ }
+ g_slist_free_full (parents, (GDestroyNotify) g_base_info_unref);
+ return func;
}
/**