aboutsummaryrefslogtreecommitdiffstats
path: root/buf.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2012-07-16 16:28:47 +0800
committerDaniel Veillard <veillard@redhat.com>2012-07-23 14:24:27 +0800
commit61551a1eb75bacb32e5209635c0f3459595af54a (patch)
tree9846870885ca48e74af34a72112c5c4f272f3628 /buf.c
parent145477d8ab5d6802529b1213220f108ad23d3827 (diff)
downloadandroid_external_libxml2-61551a1eb75bacb32e5209635c0f3459595af54a.tar.gz
android_external_libxml2-61551a1eb75bacb32e5209635c0f3459595af54a.tar.bz2
android_external_libxml2-61551a1eb75bacb32e5209635c0f3459595af54a.zip
Cleanup function xmlBufResetInput() to set input from Buffer
This was scattered in a number of modules, xmlParserInputPtr have usually their base, cur and end pointer set from an xmlBuf used as input. * buf.c buf.h: add a new function implementing this setup * parser.c HTMLparser.c catalog.c parserInternals.c xmlreader.c use the new function instead of digging into the buffer in all those modules
Diffstat (limited to 'buf.c')
-rw-r--r--buf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/buf.c b/buf.c
index 520a024b..8cf6199f 100644
--- a/buf.c
+++ b/buf.c
@@ -1136,3 +1136,21 @@ xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer) {
xmlBufferFree(buffer);
return(ret);
}
+
+/**
+ * xmlBufResetInput:
+ * @buf: an xmlBufPtr
+ * @input: an xmlParserInputPtr
+ *
+ * Update the input to use the current set of pointers from the buffer.
+ *
+ * Returns -1 in case of error, 0 otherwise, in any case @buffer is freed
+ */
+int
+xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input) {
+ if ((input == NULL) || (buf == NULL))
+ return(-1);
+ input->base = input->cur = buf->content;
+ input->end = &buf->content[buf->use];
+ return(0);
+}