comparison libpurple/xmlnode.c @ 18072:3fc94e7c7056

add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
author Nathan Walp <nwalp@pidgin.im>
date Thu, 07 Jun 2007 21:14:54 +0000
parents 905d69a0ffd7
children 6050348614ab
comparison
equal deleted inserted replaced
18068:0b3d6ea61760 18072:3fc94e7c7056
331 g_return_val_if_fail(node != NULL, NULL); 331 g_return_val_if_fail(node != NULL, NULL);
332 332
333 for(c = node->child; c; c = c->next) { 333 for(c = node->child; c; c = c->next) {
334 if(c->type == XMLNODE_TYPE_DATA) { 334 if(c->type == XMLNODE_TYPE_DATA) {
335 if(!str) 335 if(!str)
336 str = g_string_new(""); 336 str = g_string_new_len(c->data, c->data_sz);
337 str = g_string_append_len(str, c->data, c->data_sz); 337 else
338 str = g_string_append_len(str, c->data, c->data_sz);
338 } 339 }
339 } 340 }
340 341
341 if (str == NULL) 342 if (str == NULL)
342 return NULL; 343 return NULL;
343 344
344 return g_string_free(str, FALSE); 345 return g_string_free(str, FALSE);
346 }
347
348 char *
349 xmlnode_get_data_unescaped(xmlnode *node)
350 {
351 char *escaped = xmlnode_get_data(node);
352
353 char *unescaped = escaped ? purple_unescape_html(escaped) : NULL;
354
355 g_free(escaped);
356
357 return unescaped;
345 } 358 }
346 359
347 static char * 360 static char *
348 xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth) 361 xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth)
349 { 362 {