diff options
author | Stefan Kost <ensonic@users.sf.net> | 2010-06-15 16:51:28 +0300 |
---|---|---|
committer | Stefan Kost <ensonic@users.sf.net> | 2010-06-15 16:51:28 +0300 |
commit | 9339cccdf2e393d6d90b360136c13ef38da97e8a (patch) | |
tree | 555f7fc24ce870d2d0572acb92162964cb77c23b /gstdoc-scangobj | |
parent | 5adb1ca7f388af2d81156f3ba4f89947f44acfae (diff) |
docs: use g_string instead of fragile static strings
Diffstat (limited to 'gstdoc-scangobj')
-rwxr-xr-x | gstdoc-scangobj | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/gstdoc-scangobj b/gstdoc-scangobj index 88a8556..b017740 100755 --- a/gstdoc-scangobj +++ b/gstdoc-scangobj @@ -138,49 +138,40 @@ $includes #endif GType *object_types = NULL; +GString *xmlstr = NULL; + static const gchar* xmlprint (gint indent, const gchar *tag, const gchar *data) { /* 20 spaces */ gchar indent_str[] = " "; - /* these need to be quite big */ - static gchar str[50000]; - gchar conv[50000]; - gchar *s2 = conv; + + /* reset */ + g_string_truncate (xmlstr, 0); + g_string_append_printf (xmlstr, "%s<%s>", &indent_str[20-indent], tag); if (data) { - const gchar *s1 = data; - while (*s1) { - switch (*s1) { + const gchar *s = data; + while (*s) { + switch (*s) { case '<': - *s2++='&'; - *s2++='l'; - *s2++='t'; - *s2++=';'; + g_string_append (xmlstr, "<"); break; case '>': - *s2++='&'; - *s2++='g'; - *s2++='t'; - *s2++=';'; + g_string_append (xmlstr, ">"); break; case '&': - *s2++='&'; - *s2++='a'; - *s2++='m'; - *s2++='p'; - *s2++=';'; + g_string_append (xmlstr, "&"); break; default: - *s2++ = *s1; + g_string_append_c (xmlstr, *s); } - s1++; + s++; } } - *s2 = '\\0'; - sprintf(str, "%s<%s>%s</%s>\\n", &indent_str[20-indent], tag, conv, tag); - return str; + g_string_append_printf (xmlstr, "</%s>", tag); + return xmlstr->str; } static gint @@ -197,12 +188,13 @@ get_object_types (void) GList *l; GstElementFactory *factory = NULL; GType type; - gint i = 0; /* get a list of features from plugins in our source module */ plugins = gst_registry_get_plugin_list (gst_registry_get_default()); + xmlstr = g_string_new (""); + while (plugins) { GList *features, *pads; GstPlugin *plugin; @@ -294,6 +286,8 @@ get_object_types (void) fputs (" </elements>\\n</plugin>\\n", inspect); fclose (inspect); } + + g_string_free (xmlstr, TRUE); g_message ("number of element factories: %d", g_list_length (factories)); |