registry: also intern the static caps
authorStefan Kost <ensonic@users.sf.net>
Mon, 18 Oct 2010 10:29:53 +0000 (13:29 +0300)
committerStefan Kost <ensonic@users.sf.net>
Fri, 3 Dec 2010 07:42:44 +0000 (09:42 +0200)
gst/gstelementfactory.c
gst/gstregistrychunks.c

index 8294691..02d8ede 100644 (file)
@@ -163,8 +163,6 @@ gst_element_factory_cleanup (GstElementFactory * factory)
     GstStaticPadTemplate *templ = item->data;
     GstCaps *caps = (GstCaps *) & (templ->static_caps);
 
-    g_free ((gchar *) templ->static_caps.string);
-
     /* FIXME: this is not threadsafe */
     if (caps->refcount == 1) {
       GstStructure *structure;
@@ -264,15 +262,18 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
   for (item = klass->padtemplates; item; item = item->next) {
     GstPadTemplate *templ = item->data;
     GstStaticPadTemplate *newt;
+    gchar *caps_string = gst_caps_to_string (templ->caps);
 
     newt = g_slice_new (GstStaticPadTemplate);
     newt->name_template = g_intern_string (templ->name_template);
     newt->direction = templ->direction;
     newt->presence = templ->presence;
     newt->static_caps.caps.refcount = 0;
-    newt->static_caps.string = gst_caps_to_string (templ->caps);
+    newt->static_caps.string = g_intern_string (caps_string);
     factory->staticpadtemplates =
         g_list_append (factory->staticpadtemplates, newt);
+
+    g_free (caps_string);
   }
   factory->numpadtemplates = klass->numpadtemplates;
 
index 9b3003e..b34dcfa 100644 (file)
@@ -505,7 +505,7 @@ gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
 
   /* unpack pad template strings */
   unpack_const_string (*in, template->name_template, end, fail);
-  unpack_string (*in, template->static_caps.string, end, fail);
+  unpack_const_string (*in, template->static_caps.string, end, fail);
 
   __gst_element_factory_add_static_pad_template (factory, template);
   GST_DEBUG ("Added pad_template %s", template->name_template);