more leak fixes

Original commit message from CVS:
more leak fixes
This commit is contained in:
Erik Walthinsen 2001-01-07 07:45:54 +00:00
parent 81aa7d16b0
commit e33b2e5908
8 changed files with 110 additions and 50 deletions

View file

@ -41,13 +41,13 @@ get_type_for_mime (const gchar *mime)
typeid = gst_type_find_by_mime (mime); typeid = gst_type_find_by_mime (mime);
if (typeid == 0) { if (typeid == 0) {
GstTypeFactory *factory = g_new0 (GstTypeFactory, 1); GstTypeFactory factory; // = g_new0 (GstTypeFactory, 1);
factory->mime = g_strdup (mime); factory.mime = g_strdup (mime);
factory->exts = NULL; factory.exts = NULL;
factory->typefindfunc = NULL; factory.typefindfunc = NULL;
typeid = gst_type_register (factory); typeid = gst_type_register (&factory);
} }
return typeid; return typeid;
} }
@ -401,13 +401,16 @@ gst_caps_load_thyself (xmlNodePtr parent)
{ {
GstCaps *caps = g_new0 (GstCaps, 1); GstCaps *caps = g_new0 (GstCaps, 1);
xmlNodePtr field = parent->childs; xmlNodePtr field = parent->childs;
gchar *content;
while (field) { while (field) {
if (!strcmp (field->name, "name")) { if (!strcmp (field->name, "name")) {
caps->name = g_strdup (xmlNodeGetContent (field)); caps->name = xmlNodeGetContent (field);
} }
if (!strcmp (field->name, "type")) { if (!strcmp (field->name, "type")) {
caps->id = get_type_for_mime (xmlNodeGetContent (field)); content = xmlNodeGetContent (field);
caps->id = get_type_for_mime (content);
g_free (content);
} }
else if (!strcmp (field->name, "properties")) { else if (!strcmp (field->name, "properties")) {
caps->properties = gst_props_load_thyself (field); caps->properties = gst_props_load_thyself (field);

View file

@ -71,6 +71,7 @@ _gst_cpu_initialize (void)
} }
GST_INFO (GST_CAT_GST_INIT, "CPU features: %s",featurelist); GST_INFO (GST_CAT_GST_INIT, "CPU features: %s",featurelist);
g_free(featurelist);
} }
GstCPUFlags GstCPUFlags

View file

@ -393,25 +393,25 @@ gst_elementfactory_load_thyself (xmlNodePtr parent)
while (children) { while (children) {
if (!strcmp(children->name, "name")) { if (!strcmp(children->name, "name")) {
factory->name = g_strdup(xmlNodeGetContent(children)); factory->name = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "longname")) { if (!strcmp(children->name, "longname")) {
factory->details->longname = g_strdup(xmlNodeGetContent(children)); factory->details->longname = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "class")) { if (!strcmp(children->name, "class")) {
factory->details->klass = g_strdup(xmlNodeGetContent(children)); factory->details->klass = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "description")) { if (!strcmp(children->name, "description")) {
factory->details->description = g_strdup(xmlNodeGetContent(children)); factory->details->description = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "version")) { if (!strcmp(children->name, "version")) {
factory->details->version = g_strdup(xmlNodeGetContent(children)); factory->details->version = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "author")) { if (!strcmp(children->name, "author")) {
factory->details->author = g_strdup(xmlNodeGetContent(children)); factory->details->author = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "copyright")) { if (!strcmp(children->name, "copyright")) {
factory->details->copyright = g_strdup(xmlNodeGetContent(children)); factory->details->copyright = xmlNodeGetContent(children);
} }
if (!strcmp(children->name, "padtemplate")) { if (!strcmp(children->name, "padtemplate")) {
GstPadTemplate *template; GstPadTemplate *template;

View file

@ -1011,7 +1011,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
while (field) { while (field) {
if (!strcmp(field->name, "nametemplate")) { if (!strcmp(field->name, "nametemplate")) {
factory->name_template = g_strdup(xmlNodeGetContent(field)); factory->name_template = xmlNodeGetContent(field);
} }
if (!strcmp(field->name, "direction")) { if (!strcmp(field->name, "direction")) {
gchar *value = xmlNodeGetContent(field); gchar *value = xmlNodeGetContent(field);
@ -1023,6 +1023,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
else if (!strcmp(value, "src")) { else if (!strcmp(value, "src")) {
factory->direction = GST_PAD_SRC; factory->direction = GST_PAD_SRC;
} }
g_free (value);
} }
if (!strcmp(field->name, "presence")) { if (!strcmp(field->name, "presence")) {
gchar *value = xmlNodeGetContent(field); gchar *value = xmlNodeGetContent(field);
@ -1033,6 +1034,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
else if (!strcmp(value, "sometimes")) { else if (!strcmp(value, "sometimes")) {
factory->presence = GST_PAD_SOMETIMES; factory->presence = GST_PAD_SOMETIMES;
} }
g_free (value);
} }
else if (!strcmp(field->name, "caps")) { else if (!strcmp(field->name, "caps")) {
factory->caps = g_list_append(factory->caps, gst_caps_load_thyself (field)); factory->caps = g_list_append(factory->caps, gst_caps_load_thyself (field));

View file

@ -205,7 +205,9 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
} else { } else {
// we have an element // we have an element
DEBUG("attempting to create element '%s'\n",arg); DEBUG("attempting to create element '%s'\n",arg);
element = gst_elementfactory_make(arg,gst_parse_unique_name(arg,priv)); ptr = gst_parse_unique_name(arg,priv);
element = gst_elementfactory_make(arg,ptr);
g_free(ptr);
if (!element) { if (!element) {
fprintf(stderr,"Couldn't create a '%s', no such element or need to run gstraemer-register?\n",arg); fprintf(stderr,"Couldn't create a '%s', no such element or need to run gstraemer-register?\n",arg);
// exit(-1); // exit(-1);

View file

@ -90,6 +90,8 @@ _gst_plugin_initialize (void)
return; return;
} }
gst_plugin_load_thyself (doc->root); gst_plugin_load_thyself (doc->root);
xmlFreeDoc (doc);
} }
static time_t static time_t
@ -155,6 +157,7 @@ gst_plugin_load_recurse (gchar *directory, gchar *name)
DIR *dir; DIR *dir;
struct dirent *dirent; struct dirent *dirent;
gboolean loaded = FALSE; gboolean loaded = FALSE;
gchar *dirname;
//g_print("recursive load of '%s' in '%s'\n", name, directory); //g_print("recursive load of '%s' in '%s'\n", name, directory);
dir = opendir(directory); dir = opendir(directory);
@ -162,9 +165,13 @@ gst_plugin_load_recurse (gchar *directory, gchar *name)
while ((dirent = readdir(dir))) { while ((dirent = readdir(dir))) {
/* don't want to recurse in place or backwards */ /* don't want to recurse in place or backwards */
if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) { if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) {
loaded = gst_plugin_load_recurse(g_strjoin("/",directory,dirent->d_name, dirname = g_strjoin("/",directory,dirent->d_name,NULL);
NULL),name); loaded = gst_plugin_load_recurse(dirname,name);
if (loaded && name) return TRUE; g_free(dirname);
if (loaded && name) {
closedir(dir);
return TRUE;
}
} }
} }
closedir(dir); closedir(dir);
@ -267,6 +274,7 @@ gst_plugin_load (const gchar *name)
GList *path; GList *path;
gchar *libspath; gchar *libspath;
GstPlugin *plugin; GstPlugin *plugin;
gchar *pluginname;
//g_print("attempting to load plugin '%s'\n",name); //g_print("attempting to load plugin '%s'\n",name);
@ -276,19 +284,28 @@ gst_plugin_load (const gchar *name)
path = _gst_plugin_paths; path = _gst_plugin_paths;
while (path != NULL) { while (path != NULL) {
if (gst_plugin_load_absolute(g_module_build_path(path->data,name))) pluginname = g_module_build_path(path->data,name);
if (gst_plugin_load_absolute(pluginname)) {
g_free(pluginname);
return TRUE; return TRUE;
}
g_free(pluginname);
libspath = g_strconcat(path->data,"/.libs",NULL); libspath = g_strconcat(path->data,"/.libs",NULL);
//g_print("trying to load '%s'\n",g_module_build_path(libspath,name)); //g_print("trying to load '%s'\n",g_module_build_path(libspath,name));
if (gst_plugin_load_absolute(g_module_build_path(libspath,name))) { pluginname = g_module_build_path(libspath,name);
g_free(libspath); g_free(libspath);
if (gst_plugin_load_absolute(pluginname)) {
g_free(pluginname);
return TRUE; return TRUE;
} }
g_free(libspath); g_free(pluginname);
//g_print("trying to load '%s' from '%s'\n",name,path->data); //g_print("trying to load '%s' from '%s'\n",name,path->data);
if (gst_plugin_load_recurse(path->data,g_module_build_path("",name))) { pluginname = g_module_build_path("",name);
if (gst_plugin_load_recurse(path->data,pluginname)) {
g_free(pluginname);
return TRUE; return TRUE;
} }
g_free(pluginname);
path = g_list_next(path); path = g_list_next(path);
} }
return FALSE; return FALSE;
@ -738,6 +755,7 @@ gst_plugin_load_thyself (xmlNodePtr parent)
xmlNodePtr kinderen; xmlNodePtr kinderen;
gint elementcount = 0; gint elementcount = 0;
gint typecount = 0; gint typecount = 0;
gchar *pluginname;
kinderen = parent->childs; // Dutch invasion :-) kinderen = parent->childs; // Dutch invasion :-)
while (kinderen) { while (kinderen) {
@ -750,20 +768,21 @@ gst_plugin_load_thyself (xmlNodePtr parent)
while (field) { while (field) {
if (!strcmp(field->name, "name")) { if (!strcmp(field->name, "name")) {
if (gst_plugin_find(xmlNodeGetContent(field))) { pluginname = xmlNodeGetContent(field);
if (gst_plugin_find(pluginname)) {
g_free(pluginname);
g_free(plugin); g_free(plugin);
plugin = NULL; plugin = NULL;
break; break;
} } else {
else { plugin->name = pluginname;
plugin->name = g_strdup(xmlNodeGetContent(field));
} }
} }
else if (!strcmp(field->name, "longname")) { else if (!strcmp(field->name, "longname")) {
plugin->longname = g_strdup(xmlNodeGetContent(field)); plugin->longname = xmlNodeGetContent(field);
} }
else if (!strcmp(field->name, "filename")) { else if (!strcmp(field->name, "filename")) {
plugin->filename = g_strdup(xmlNodeGetContent(field)); plugin->filename = xmlNodeGetContent(field);
} }
else if (!strcmp(field->name, "element")) { else if (!strcmp(field->name, "element")) {
GstElementFactory *factory = gst_elementfactory_load_thyself(field); GstElementFactory *factory = gst_elementfactory_load_thyself(field);

View file

@ -469,24 +469,35 @@ static xmlNodePtr
gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent) gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent)
{ {
xmlNodePtr subtree; xmlNodePtr subtree;
gchar *str;
switch (entry->propstype) { switch (entry->propstype) {
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID_NUM:
subtree = xmlNewChild (parent, NULL, "int", NULL); subtree = xmlNewChild (parent, NULL, "int", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
xmlNewProp (subtree, "value", g_strdup_printf ("%d", entry->data.int_data)); str = g_strdup_printf ("%d", entry->data.int_data);
xmlNewProp (subtree, "value", str);
g_free(str);
break; break;
case GST_PROPS_INT_RANGE_ID_NUM: case GST_PROPS_INT_RANGE_ID_NUM:
subtree = xmlNewChild (parent, NULL, "range", NULL); subtree = xmlNewChild (parent, NULL, "range", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
xmlNewProp (subtree, "min", g_strdup_printf ("%d", entry->data.int_range_data.min)); str = g_strdup_printf ("%d", entry->data.int_range_data.min);
xmlNewProp (subtree, "max", g_strdup_printf ("%d", entry->data.int_range_data.max)); xmlNewProp (subtree, "min", str);
g_free(str);
str = g_strdup_printf ("%d", entry->data.int_range_data.max);
xmlNewProp (subtree, "max", str);
g_free(str);
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID_NUM:
xmlAddChild (parent, xmlNewComment (g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data))); str = g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data);
xmlAddChild (parent, xmlNewComment (str));
g_free(str);
subtree = xmlNewChild (parent, NULL, "fourcc", NULL); subtree = xmlNewChild (parent, NULL, "fourcc", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
xmlNewProp (subtree, "hexvalue", g_strdup_printf ("%08x", entry->data.fourcc_data)); str = g_strdup_printf ("%08x", entry->data.fourcc_data);
xmlNewProp (subtree, "hexvalue", str);
g_free(str);
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID_NUM:
subtree = xmlNewChild (parent, NULL, "boolean", NULL); subtree = xmlNewChild (parent, NULL, "boolean", NULL);
@ -541,30 +552,49 @@ static GstPropsEntry*
gst_props_load_thyself_func (xmlNodePtr field) gst_props_load_thyself_func (xmlNodePtr field)
{ {
GstPropsEntry *entry; GstPropsEntry *entry;
gchar *prop;
entry = g_new0 (GstPropsEntry, 1); entry = g_new0 (GstPropsEntry, 1);
if (!strcmp(field->name, "int")) { if (!strcmp(field->name, "int")) {
entry->propstype = GST_PROPS_INT_ID_NUM; entry->propstype = GST_PROPS_INT_ID_NUM;
entry->propid = g_quark_from_string (xmlGetProp(field, "name")); prop = xmlGetProp(field, "name");
sscanf (xmlGetProp(field, "value"), "%d", &entry->data.int_data); entry->propid = g_quark_from_string (prop);
g_free (prop);
prop = xmlGetProp(field, "value");
sscanf (prop, "%d", &entry->data.int_data);
g_free (prop);
} }
else if (!strcmp(field->name, "range")) { else if (!strcmp(field->name, "range")) {
entry->propstype = GST_PROPS_INT_RANGE_ID_NUM; entry->propstype = GST_PROPS_INT_RANGE_ID_NUM;
entry->propid = g_quark_from_string (xmlGetProp(field, "name")); prop = xmlGetProp(field, "name");
sscanf (xmlGetProp(field, "min"), "%d", &entry->data.int_range_data.min); entry->propid = g_quark_from_string (prop);
sscanf (xmlGetProp(field, "max"), "%d", &entry->data.int_range_data.max); g_free (prop);
prop = xmlGetProp (field, "min");
sscanf (prop, "%d", &entry->data.int_range_data.min);
g_free (prop);
prop = xmlGetProp (field, "min");
sscanf (prop, "%d", &entry->data.int_range_data.max);
g_free (prop);
} }
else if (!strcmp(field->name, "boolean")) { else if (!strcmp(field->name, "boolean")) {
entry->propstype = GST_PROPS_BOOL_ID_NUM; entry->propstype = GST_PROPS_BOOL_ID_NUM;
entry->propid = g_quark_from_string (xmlGetProp(field, "name")); prop = xmlGetProp(field, "name");
if (!strcmp (xmlGetProp(field, "value"), "false")) entry->data.bool_data = 0; entry->propid = g_quark_from_string (prop);
g_free (prop);
prop = xmlGetProp (field, "value");
if (!strcmp (prop, "false")) entry->data.bool_data = 0;
else entry->data.bool_data = 1; else entry->data.bool_data = 1;
g_free (prop);
} }
else if (!strcmp(field->name, "fourcc")) { else if (!strcmp(field->name, "fourcc")) {
entry->propstype = GST_PROPS_FOURCC_ID_NUM; entry->propstype = GST_PROPS_FOURCC_ID_NUM;
entry->propid = g_quark_from_string (xmlGetProp(field, "name")); prop = xmlGetProp(field, "name");
sscanf (xmlGetProp(field, "hexvalue"), "%08x", &entry->data.fourcc_data); entry->propid = g_quark_from_string (prop);
g_free (prop);
prop = xmlGetProp (field, "hexvalue");
sscanf (prop, "%08x", &entry->data.fourcc_data);
g_free (prop);
} }
return entry; return entry;
@ -583,6 +613,7 @@ gst_props_load_thyself (xmlNodePtr parent)
{ {
GstProps *props = g_new0 (GstProps, 1); GstProps *props = g_new0 (GstProps, 1);
xmlNodePtr field = parent->childs; xmlNodePtr field = parent->childs;
gchar *prop;
while (field) { while (field) {
if (!strcmp (field->name, "list")) { if (!strcmp (field->name, "list")) {
@ -591,7 +622,9 @@ gst_props_load_thyself (xmlNodePtr parent)
entry = g_new0 (GstPropsEntry, 1); entry = g_new0 (GstPropsEntry, 1);
entry->propstype = GST_PROPS_LIST_ID_NUM; entry->propstype = GST_PROPS_LIST_ID_NUM;
entry->propid = g_quark_from_string (xmlGetProp(field, "name")); prop = xmlGetProp (field, "name");
entry->propid = g_quark_from_string (prop);
g_free (prop);
while (subfield) { while (subfield) {
GstPropsEntry *subentry = gst_props_load_thyself_func (subfield); GstPropsEntry *subentry = gst_props_load_thyself_func (subfield);

View file

@ -272,10 +272,10 @@ gst_typefactory_load_thyself (xmlNodePtr parent)
while (field) { while (field) {
if (!strcmp (field->name, "mime")) { if (!strcmp (field->name, "mime")) {
factory->mime = g_strdup (xmlNodeGetContent (field)); factory->mime = xmlNodeGetContent (field);
} }
else if (!strcmp (field->name, "extensions")) { else if (!strcmp (field->name, "extensions")) {
factory->exts = g_strdup (xmlNodeGetContent (field)); factory->exts = xmlNodeGetContent (field);
} }
else if (!strcmp (field->name, "typefind")) { else if (!strcmp (field->name, "typefind")) {
factory->typefindfunc = gst_type_typefind_dummy; factory->typefindfunc = gst_type_typefind_dummy;