diff --git a/ChangeLog b/ChangeLog index 223f19bfdf..f4b1d39512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-10-09 Tim-Philipp Müller + + * gst/gstplugin.c: + * gst/gstplugin.h: + * gst/gstregistrybinary.c: + * gst/gstregistryxml.c: + Put more strings into the GLib quark table. No need to keep + a hundred-something copies of identical version strings, + license strings, package name strings and package origin + strings around. + 2007-10-09 Tim-Philipp Müller * docs/manual/advanced-dataaccess.xml: diff --git a/gst/gstplugin.c b/gst/gstplugin.c index a0d25b0b6d..bd43f4bc88 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -495,28 +495,22 @@ gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src) { dest->major_version = src->major_version; dest->minor_version = src->minor_version; - dest->name = g_strdup (src->name); + dest->name = g_intern_string (src->name); + /* maybe intern the description too, just for convenience? */ dest->description = g_strdup (src->description); dest->plugin_init = src->plugin_init; - dest->version = g_strdup (src->version); - dest->license = g_strdup (src->license); - dest->source = g_strdup (src->source); - dest->package = g_strdup (src->package); - dest->origin = g_strdup (src->origin); + dest->version = g_intern_string (src->version); + dest->license = g_intern_string (src->license); + dest->source = g_intern_string (src->source); + dest->package = g_intern_string (src->package); + dest->origin = g_intern_string (src->origin); } /* unused */ static void gst_plugin_desc_free (GstPluginDesc * desc) { - g_free (desc->name); g_free (desc->description); - g_free (desc->version); - g_free (desc->license); - g_free (desc->source); - g_free (desc->package); - g_free (desc->origin); - memset (desc, 0, sizeof (GstPluginDesc)); } diff --git a/gst/gstplugin.h b/gst/gstplugin.h index c1b14966be..cfc28f6f29 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -110,14 +110,14 @@ typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin); struct _GstPluginDesc { gint major_version; gint minor_version; - gchar *name; + const gchar *name; gchar *description; GstPluginInitFunc plugin_init; - gchar *version; - gchar *license; - gchar *source; - gchar *package; - gchar *origin; + const gchar *version; + const gchar *license; + const gchar *source; + const gchar *package; + const gchar *origin; gpointer _gst_reserved[GST_PADDING]; }; diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 6fd74b5398..ad59971738 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -823,14 +823,14 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in) plugin->file_size = pe->file_size; /* unpack plugin element strings */ - unpack_string (*in, plugin->desc.name); + unpack_const_string (*in, plugin->desc.name); unpack_string (*in, plugin->desc.description); unpack_string (*in, plugin->filename); - unpack_string (*in, plugin->desc.version); - unpack_string (*in, plugin->desc.license); - unpack_string (*in, plugin->desc.source); - unpack_string (*in, plugin->desc.package); - unpack_string (*in, plugin->desc.origin); + unpack_const_string (*in, plugin->desc.version); + unpack_const_string (*in, plugin->desc.license); + unpack_const_string (*in, plugin->desc.source); + unpack_const_string (*in, plugin->desc.package); + unpack_const_string (*in, plugin->desc.origin); GST_LOG ("read strings for '%s'", plugin->desc.name); plugin->basename = g_path_get_basename (plugin->filename); diff --git a/gst/gstregistryxml.c b/gst/gstregistryxml.c index b9bfa40506..75a1e6e1c7 100644 --- a/gst/gstregistryxml.c +++ b/gst/gstregistryxml.c @@ -404,7 +404,7 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list) if (g_str_equal (tag, "name")) { int ret; - ret = read_string (reader, &plugin->desc.name, FALSE); + ret = read_const_interned_string (reader, &plugin->desc.name, FALSE); GST_LOG ("name ret=%d, name=%s", ret, plugin->desc.name); if (!ret) break; @@ -422,31 +422,31 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list) GST_LOG ("filename %s", plugin->filename); plugin->basename = g_path_get_basename (plugin->filename); } else if (g_str_equal (tag, "version")) { - if (!read_string (reader, &plugin->desc.version, TRUE)) { + if (!read_const_interned_string (reader, &plugin->desc.version, TRUE)) { GST_WARNING ("version field was invalid in registry"); break; } GST_LOG ("version %s", plugin->desc.version); } else if (g_str_equal (tag, "license")) { - if (!read_string (reader, &plugin->desc.license, TRUE)) { + if (!read_const_interned_string (reader, &plugin->desc.license, TRUE)) { GST_WARNING ("license field was invalid in registry"); break; } GST_LOG ("license %s", plugin->desc.license); } else if (g_str_equal (tag, "source")) { - if (!read_string (reader, &plugin->desc.source, TRUE)) { + if (!read_const_interned_string (reader, &plugin->desc.source, TRUE)) { GST_WARNING ("source field was invalid in registry"); break; } GST_LOG ("source %s", plugin->desc.source); } else if (g_str_equal (tag, "package")) { - if (!read_string (reader, &plugin->desc.package, TRUE)) { + if (!read_const_interned_string (reader, &plugin->desc.package, TRUE)) { GST_WARNING ("package field was invalid in registry"); break; } GST_LOG ("package %s", plugin->desc.package); } else if (g_str_equal (tag, "origin")) { - if (!read_string (reader, &plugin->desc.origin, TRUE)) { + if (!read_const_interned_string (reader, &plugin->desc.origin, TRUE)) { GST_WARNING ("failed to read origin"); break; }