diff options
author | <robert.mcqueen@collabora.co.uk> | 2006-07-21 01:08:10 +0000 |
---|---|---|
committer | <robert.mcqueen@collabora.co.uk> | 2006-07-21 01:08:10 +0000 |
commit | 94025d89d8f545857c6d012898aa3edd4a0fac83 (patch) | |
tree | d6edd432304eee32effbd89c5b28f4970dcddfed | |
parent | 88f8d5dd3966bee4239e1e6c9f98b9397e91b1bd (diff) |
factor out lm_message_node_steal_children and properly reset the parent of all stolen child nodes
-rw-r--r-- | src/gabble-connection.c | 7 | ||||
-rw-r--r-- | src/util.c | 19 | ||||
-rw-r--r-- | src/util.h | 1 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/gabble-connection.c b/src/gabble-connection.c index a156735f3..afd73b338 100644 --- a/src/gabble-connection.c +++ b/src/gabble-connection.c @@ -2361,12 +2361,7 @@ _gabble_connection_send_iq_error (GabbleConnection *conn, lm_message_node_set_attribute (msg->node, "id", id); - if (iq_node->children != NULL) - { - msg->node->children = iq_node->children; - msg->node->children->parent = msg->node; - iq_node->children = NULL; - } + lm_message_node_steal_children (msg->node, iq_node); gabble_xmpp_error_to_node (error, msg->node); diff --git a/src/util.c b/src/util.c index 25a91ccc7..8790b5ec9 100644 --- a/src/util.c +++ b/src/util.c @@ -65,3 +65,22 @@ lm_message_node_add_own_nick (LmMessageNode *node, g_free (nick); } +void +lm_message_node_steal_children (LmMessageNode *snatcher, + LmMessageNode *mum) +{ + LmMessageNode *baby; + + g_return_if_fail (snatcher->children == NULL); + + if (mum->children == NULL) + return; + + snatcher->children = mum->children; + mum->children = NULL; + + for (baby = snatcher->children; + baby != NULL; + baby = baby->next) + baby->parent = snatcher; +} diff --git a/src/util.h b/src/util.h index 32fa7ee76..a507b19f0 100644 --- a/src/util.h +++ b/src/util.h @@ -30,5 +30,6 @@ gboolean g_strdiff (const gchar *left, const gchar *right); void lm_message_node_add_nick (LmMessageNode *node, const gchar *nick); void lm_message_node_add_own_nick (LmMessageNode *node, GabbleConnection *conn); +void lm_message_node_steal_children (LmMessageNode *snatcher, LmMessageNode *mum); #endif /* __GABBLE_UTIL_H__ */ |