[librest] Accept -1 len in rest_xml_parser_parse_from_data



commit 68d3302c55f38072010b303596775f7a0ee57f12
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun Jun 17 13:28:04 2012 +0200

    Accept -1 len in rest_xml_parser_parse_from_data
    
    This means that the passed in string is nul-terminated and that
    rest_xml_parser_parse_from_data should get its length with strlen.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=657032

 rest/rest-xml-parser.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index 690d757..49b49b4 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -20,6 +20,7 @@
  *
  */
 
+#include <string.h>
 #include <libxml/xmlreader.h>
 
 #include "rest-private.h"
@@ -56,7 +57,7 @@ rest_xml_parser_new (void)
  * rest_xml_parser_parse_from_data:
  * @parser: a #RestXmlParser
  * @data: the XML content to parse
- * @len: the length of @data
+ * @len: the length of @data, or -1 if @data is a nul-terminated string
  *
  * Parse the XML in @data, and return a new #RestXmlNode.  If @data is invalid
  * XML, %NULL is returned.
@@ -82,6 +83,9 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
 
   g_return_val_if_fail (REST_IS_XML_PARSER (parser), NULL);
 
+  if (len == -1)
+    len = strlen (data);
+
   _rest_setup_debugging ();
 
   reader = xmlReaderForMemory (data,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]