parser/expat: reduce code duplication
This commit is contained in:
@@ -114,18 +114,7 @@ static void _start_element(void *userdata,
|
||||
/* something terrible happened */
|
||||
/* FIXME: shutdown disconnect */
|
||||
xmpp_error(parser->ctx, "parser", "oops, where did our stanza go?");
|
||||
} else if (!parser->stanza) {
|
||||
/* starting a new toplevel stanza */
|
||||
parser->stanza = xmpp_stanza_new(parser->ctx);
|
||||
if (!parser->stanza) {
|
||||
/* FIXME: can't allocate, disconnect */
|
||||
}
|
||||
xmpp_stanza_set_name(parser->stanza, name);
|
||||
_set_attributes(parser->stanza, attrs);
|
||||
if (ns)
|
||||
xmpp_stanza_set_ns(parser->stanza, ns);
|
||||
} else {
|
||||
/* starting a child of parser->stanza */
|
||||
child = xmpp_stanza_new(parser->ctx);
|
||||
if (!child) {
|
||||
/* FIXME: can't allocate, disconnect */
|
||||
@@ -135,13 +124,10 @@ static void _start_element(void *userdata,
|
||||
if (ns)
|
||||
xmpp_stanza_set_ns(child, ns);
|
||||
|
||||
/* add child to parent */
|
||||
if (parser->stanza != NULL) {
|
||||
xmpp_stanza_add_child(parser->stanza, child);
|
||||
|
||||
/* the child is owned by the toplevel stanza now */
|
||||
xmpp_stanza_release(child);
|
||||
|
||||
/* make child the current stanza */
|
||||
}
|
||||
parser->stanza = child;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user