Fix memory leaks:

Original commit message from CVS:
reviewed by: David Schleef  <ds@schleef.org>
Fix memory leaks:
* gst/gstcaps.c: (gst_caps_to_string):
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_add_path_list_func),
(gst_xml_registry_parse_padtemplate):
This commit is contained in:
David Schleef 2004-02-02 20:25:02 +00:00
parent 031bcfd561
commit 30bec331af
3 changed files with 28 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2004-02-02 Jon Trowbridge <trow@gnu.org>
reviewed by: David Schleef <ds@schleef.org>
Fix memory leaks:
* gst/gstcaps.c: (gst_caps_to_string):
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_add_path_list_func),
(gst_xml_registry_parse_padtemplate):
2004-02-02 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gstelement.c: (gst_element_default_error):

View file

@ -1026,6 +1026,7 @@ gchar *gst_caps_to_string (const GstCaps *caps)
int i;
GstStructure *structure;
GString *s;
char *sstr;
/* NOTE: This function is potentially called by the debug system,
* so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
@ -1046,13 +1047,17 @@ gchar *gst_caps_to_string (const GstCaps *caps)
}
s = g_string_new("");
structure = gst_caps_get_structure (caps, 0);
g_string_append(s, gst_structure_to_string(structure));
sstr = gst_structure_to_string(structure);
g_string_append(s, sstr);
g_free(sstr);
for(i=1;i<caps->structs->len;i++){
structure = gst_caps_get_structure (caps, i);
g_string_append(s, "; ");
g_string_append(s, gst_structure_to_string(structure));
sstr = gst_structure_to_string(structure);
g_string_append(s, sstr);
g_free(sstr);
}
return g_string_free(s, FALSE);

View file

@ -375,9 +375,9 @@ gst_xml_registry_get_perms_func (GstXMLRegistry *registry)
static void
gst_xml_registry_add_path_list_func (GstXMLRegistry *registry)
{
FILE *reg;
FILE *reg = NULL;
GMarkupParseContext *context;
gchar *text;
gchar *text = NULL;
gssize size;
GError *error = NULL;
@ -385,7 +385,7 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry)
registry, NULL);
if (! (reg = fopen (registry->location, "r"))) {
return;
goto finished;
}
/* slightly allocate more as gmarkup reads too much */
@ -399,9 +399,7 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry)
if (error) {
GST_ERROR ("parsing registry %s: %s\n",
registry->location, error->message);
g_free (text);
fclose (reg);
return;
goto finished;
}
if (registry->state == GST_XML_REGISTRY_PATHS_DONE)
@ -410,7 +408,12 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry)
size = fread (text, 1, BLOCK_SIZE, reg);
}
fclose (reg);
finished:
g_markup_parse_context_free (context);
if (reg)
fclose (reg);
g_free (text);
}
@ -837,6 +840,7 @@ gst_xml_registry_parse_padtemplate (GMarkupParseContext *context, const gchar *t
char *s;
s = g_strndup (text, text_len);
g_assert (registry->caps == NULL);
registry->caps = gst_caps_from_string (s);
if (registry->caps == NULL) {
g_critical ("Could not parse caps: length %d, content: %*s\n", text_len, text_len, text);