# HG changeset patch # User Nathan Walp # Date 1181250894 0 # Node ID 3fc94e7c7056618adf706d6c42d0ba5c0e36f3c1 # Parent 0b3d6ea617608325d3b66b9c353a1e9e71041bd5 add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc diff -r 0b3d6ea61760 -r 3fc94e7c7056 libpurple/xmlnode.c --- a/libpurple/xmlnode.c Thu Jun 07 14:48:33 2007 +0000 +++ b/libpurple/xmlnode.c Thu Jun 07 21:14:54 2007 +0000 @@ -333,8 +333,9 @@ for(c = node->child; c; c = c->next) { if(c->type == XMLNODE_TYPE_DATA) { if(!str) - str = g_string_new(""); - str = g_string_append_len(str, c->data, c->data_sz); + str = g_string_new_len(c->data, c->data_sz); + else + str = g_string_append_len(str, c->data, c->data_sz); } } @@ -344,6 +345,18 @@ return g_string_free(str, FALSE); } +char * +xmlnode_get_data_unescaped(xmlnode *node) +{ + char *escaped = xmlnode_get_data(node); + + char *unescaped = escaped ? purple_unescape_html(escaped) : NULL; + + g_free(escaped); + + return unescaped; +} + static char * xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth) { diff -r 0b3d6ea61760 -r 3fc94e7c7056 libpurple/xmlnode.h --- a/libpurple/xmlnode.h Thu Jun 07 14:48:33 2007 +0000 +++ b/libpurple/xmlnode.h Thu Jun 07 21:14:54 2007 +0000 @@ -124,14 +124,24 @@ void xmlnode_insert_data(xmlnode *node, const char *data, gssize size); /** - * Gets data from a node. + * Gets (escaped) data from a node. * * @param node The node to get data from. * - * @return The data from the node. You must g_free + * @return The data from the node. This data is in raw escaped format. + * You must g_free this string when finished using it. + */ +char *xmlnode_get_data(xmlnode *node); + +/** + * Gets unescaped data from a node. + * + * @param node The node to get data from. + * + * @return The data from the node, in unescaped form. You must g_free * this string when finished using it. */ -char *xmlnode_get_data(xmlnode *node); +char *xmlnode_get_data_unescaped(xmlnode *node); /** * Sets an attribute for a node.