[libxml2] Make xmlNewSAXParserCtx take a const sax handler
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Make xmlNewSAXParserCtx take a const sax handler
- Date: Thu, 1 Sep 2022 00:40:06 +0000 (UTC)
commit 65dc8a63aca578945e6121b4e5b93621d1733d9e
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu Sep 1 00:13:19 2022 +0200
Make xmlNewSAXParserCtx take a const sax handler
Also improve documentation.
HTMLparser.c | 8 +++++---
include/libxml/HTMLparser.h | 4 ++--
include/libxml/parser.h | 3 ++-
parserInternals.c | 9 +++++----
4 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/HTMLparser.c b/HTMLparser.c
index d5fb6ae3..f29138ac 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5047,7 +5047,8 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
*/
static int
-htmlInitParserCtxt(htmlParserCtxtPtr ctxt, htmlSAXHandler *sax, void *userData)
+htmlInitParserCtxt(htmlParserCtxtPtr ctxt, const htmlSAXHandler *sax,
+ void *userData)
{
if (ctxt == NULL) return(-1);
memset(ctxt, 0, sizeof(htmlParserCtxt));
@@ -5181,13 +5182,14 @@ htmlNewParserCtxt(void)
* @sax: SAX handler
* @userData: user data
*
- * Allocate and initialize a new parser context.
+ * Allocate and initialize a new SAX parser context. If userData is NULL,
+ * the parser context will be passed as user data.
*
* Returns the htmlParserCtxtPtr or NULL in case of allocation error
*/
htmlParserCtxtPtr
-htmlNewSAXParserCtxt(htmlSAXHandlerPtr sax, void *userData)
+htmlNewSAXParserCtxt(const htmlSAXHandler *sax, void *userData)
{
xmlParserCtxtPtr ctxt;
diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h
index 9fa01be1..e0e96833 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -114,8 +114,8 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlNewParserCtxt(void);
XMLPUBFUN htmlParserCtxtPtr XMLCALL
- htmlNewSAXParserCtxt(htmlSAXHandlerPtr sax,
- void *userData);
+ htmlNewSAXParserCtxt(const htmlSAXHandler *sax,
+ void *userData);
XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlCreateMemoryParserCtxt(const char *buffer,
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index f96148b5..ca5c93c9 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -990,7 +990,8 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlNewParserCtxt (void);
XMLPUBFUN xmlParserCtxtPtr XMLCALL
- xmlNewSAXParserCtxt (xmlSAXHandlerPtr sax, void *userData);
+ xmlNewSAXParserCtxt (const xmlSAXHandler *sax,
+ void *userData);
XMLPUBFUN int XMLCALL
xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
XMLPUBFUN void XMLCALL
diff --git a/parserInternals.c b/parserInternals.c
index eb12e629..4e119535 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1455,7 +1455,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
*/
static int
-xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, xmlSAXHandlerPtr sax,
+xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
void *userData)
{
xmlParserInputPtr input;
@@ -1765,13 +1765,14 @@ xmlNewParserCtxt(void)
* @sax: SAX handler
* @userData: user data
*
- * Allocate and initialize a new SAX parser context.
+ * Allocate and initialize a new SAX parser context. If userData is NULL,
+ * the parser context will be passed as user data.
*
- * Returns the xmlParserCtxtPtr or NULL
+ * Returns the xmlParserCtxtPtr or NULL if memory allocation failed.
*/
xmlParserCtxtPtr
-xmlNewSAXParserCtxt(xmlSAXHandlerPtr sax, void *userData)
+xmlNewSAXParserCtxt(const xmlSAXHandler *sax, void *userData)
{
xmlParserCtxtPtr ctxt;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]