X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=obt%2Fxml.c;h=69810d77ee9374a1b3c46b20aa3ff038f84d70df;hb=4f8503c2c5aa4210c923269626b67c5919326c46;hp=92e234306fbaaf201f7475623b644a0e1c469c82;hpb=31f0c8c1ad8c9acf369ab8336765f4bf673b8e21;p=chaz%2Fopenbox diff --git a/obt/xml.c b/obt/xml.c index 92e23430..69810d77 100644 --- a/obt/xml.c +++ b/obt/xml.c @@ -52,12 +52,12 @@ struct _ObtXmlInst { static void destfunc(struct Callback *c) { g_free(c->tag); - g_free(c); + g_slice_free(struct Callback, c); } ObtXmlInst* obt_xml_instance_new(void) { - ObtXmlInst *i = g_new(ObtXmlInst, 1); + ObtXmlInst *i = g_slice_new(ObtXmlInst); i->ref = 1; i->xdg_paths = obt_paths_new(); i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, @@ -78,7 +78,7 @@ void obt_xml_instance_unref(ObtXmlInst *i) if (i && --i->ref == 0) { obt_paths_unref(i->xdg_paths); g_hash_table_destroy(i->callbacks); - g_free(i); + g_slice_free(ObtXmlInst, i); } } @@ -104,7 +104,7 @@ void obt_xml_register(ObtXmlInst *i, const gchar *tag, return; } - c = g_new(struct Callback, 1); + c = g_slice_new(struct Callback); c->tag = g_strdup(tag); c->func = func; c->data = data; @@ -135,7 +135,8 @@ static gboolean load_file(ObtXmlInst *i, /* XML_PARSE_BLANKS is needed apparently, or the tree can end up with extra nodes in it. */ i->doc = xmlReadFile(path, NULL, (XML_PARSE_NOBLANKS | - XML_PARSE_RECOVER)); + XML_PARSE_RECOVER | + XML_PARSE_XINCLUDE)); if (i->doc) { i->root = xmlDocGetRootElement(i->doc); if (!i->root) { @@ -300,8 +301,10 @@ void obt_xml_tree(ObtXmlInst *i, xmlNodePtr node) g_assert(i->doc); /* a doc is open? */ while (node) { - struct Callback *c = g_hash_table_lookup(i->callbacks, node->name); - if (c) c->func(node, c->data); + if (node->name) { + struct Callback *c = g_hash_table_lookup(i->callbacks, node->name); + if (c) c->func(node, c->data); + } node = node->next; } }