repository: Squash memory leak in _get_func and fix up style
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 12 Dec 2011 21:14:57 +0000 (16:14 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Fri, 6 Jan 2012 20:00:39 +0000 (15:00 -0500)
girepository/giobjectinfo.c

index fbf5d8ab2584d56d72bda2285991b907fc6b0316..4aca8bd45f48e24cc86845b79c90614f950b17c1 100644 (file)
@@ -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;
 }
 
 /**