[glade] glade_util_get_type_from_name() Better logical memory management.



commit b915455d92a233f6df757708a3d884705b26889e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Apr 14 17:58:41 2013 +0900

    glade_util_get_type_from_name() Better logical memory management.
    
    Never free the passed type name.

 gladeui/glade-utils.c          | 4 +++-
 gladeui/glade-widget-adaptor.c | 8 +++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index 570cd7e..1ad1fa6 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -134,7 +134,9 @@ glade_util_get_type_from_name (const gchar *name, gboolean have_func)
         {
           g_warning (_("We could not find the symbol \"%s\""), func_name);
         }
-      g_free (func_name);
+
+      if (!have_func)
+       g_free (func_name);
     }
 
   if (type == 0)
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 27d3375..b761de2 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -2681,9 +2681,11 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
     }
   else if ((func_name =
             glade_xml_get_property_string (class_node,
-                                           GLADE_TAG_GET_TYPE_FUNCTION)) !=
-           NULL)
-    object_type = glade_util_get_type_from_name (func_name, TRUE);
+                                           GLADE_TAG_GET_TYPE_FUNCTION)) != NULL)
+    {
+      object_type = glade_util_get_type_from_name (func_name, TRUE);
+      g_free (func_name);
+    }
   else
     {
       GType type_iter;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]