projects
/
platform
/
upstream
/
gst-common.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5adb1ca
)
docs: use g_string instead of fragile static strings
author
Stefan Kost
<ensonic@users.sf.net>
Tue, 15 Jun 2010 13:51:28 +0000
(16:51 +0300)
committer
Stefan Kost
<ensonic@users.sf.net>
Tue, 15 Jun 2010 13:51:28 +0000
(16:51 +0300)
gstdoc-scangobj
patch
|
blob
|
history
diff --git
a/gstdoc-scangobj
b/gstdoc-scangobj
index
88a8556
..
b017740
100755
(executable)
--- a/
gstdoc-scangobj
+++ b/
gstdoc-scangobj
@@
-138,49
+138,40
@@
$includes
#endif
GType *object_types = NULL;
#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[] = " ";
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];
- g
char conv[50000]
;
- g
char *s2 = conv
;
+
+ /* reset */
+ g
_string_truncate (xmlstr, 0)
;
+ g
_string_append_printf (xmlstr, "%s<%s>", &indent_str[20-indent], tag)
;
if (data) {
if (data) {
- const gchar *s
1
= data;
- while (*s
1
) {
- switch (*s
1
) {
+ const gchar *s = data;
+ while (*s) {
+ switch (*s) {
case '<':
case '<':
- *s2++='&';
- *s2++='l';
- *s2++='t';
- *s2++=';';
+ g_string_append (xmlstr, "<");
break;
case '>':
break;
case '>':
- *s2++='&';
- *s2++='g';
- *s2++='t';
- *s2++=';';
+ g_string_append (xmlstr, ">");
break;
case '&':
break;
case '&':
- *s2++='&';
- *s2++='a';
- *s2++='m';
- *s2++='p';
- *s2++=';';
+ g_string_append (xmlstr, "&");
break;
default:
break;
default:
-
*s2++ = *s1
;
+
g_string_append_c (xmlstr, *s)
;
}
}
- s
1
++;
+ 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
}
static gint
@@
-197,12
+188,13
@@
get_object_types (void)
GList *l;
GstElementFactory *factory = NULL;
GType type;
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());
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;
while (plugins) {
GList *features, *pads;
GstPlugin *plugin;
@@
-294,6
+286,8
@@
get_object_types (void)
fputs (" </elements>\\n</plugin>\\n", inspect);
fclose (inspect);
}
fputs (" </elements>\\n</plugin>\\n", inspect);
fclose (inspect);
}
+
+ g_string_free (xmlstr, TRUE);
g_message ("number of element factories: %d", g_list_length (factories));
g_message ("number of element factories: %d", g_list_length (factories));