Skip to content

Commit

Permalink
Use xmlReadMemory instead of xmlParseMemory
Browse files Browse the repository at this point in the history
xmlParseMemory is deprecated since v2.11.0[1][2]. Although it doesn't
cause compiler warnings itself, it doesn't return line/column
information UNLESS xmlLineNumbersDefault(1) is called, which IS
deprecated AND causes compiler warnings.

[1] https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.11.0
[2] https://gitlab.gnome.org/GNOME/libxml2/-/commit/0e49f8826a71be2c56b8f7e86a5c103dd21a8f3f
  • Loading branch information
WGH- committed May 30, 2024
1 parent 94c5708 commit 6395660
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions libxml2.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ static void simpleStructErrorCallback(
static struct xsdParserResult parseSchema(
xmlSchemaParserCtxtPtr schemaParserCtxt,
const short int options) {
xmlLineNumbersDefault(1);
bool err = false;
struct xsdParserResult parserResult;
errCtx ectx = initErrCtx(1, GO_ERR_INIT);
Expand Down Expand Up @@ -253,7 +252,6 @@ static struct xsdParserResult cParseMemSchema(const void* xsd,
static struct xmlParserResult cParseDoc(const void* goXmlSource,
const int goXmlSourceLen,
const short int options) {
xmlLineNumbersDefault(1);
bool err = false;
struct xmlParserResult parserResult;
errCtx ectx = initErrCtx(1, GO_ERR_INIT);
Expand Down Expand Up @@ -284,7 +282,7 @@ static struct xmlParserResult cParseDoc(const void* goXmlSource,
xmlSetGenericErrorFunc(NULL, noOutputCallback);
}
doc = xmlParseMemory(goXmlSource, goXmlSourceLen);
doc = xmlReadMemory(goXmlSource, goXmlSourceLen, NULL, NULL, 0);
xmlFreeParserCtxt(xmlParserCtxt);
if (doc == NULL) {
Expand All @@ -306,8 +304,6 @@ static struct xmlParserResult cParseDoc(const void* goXmlSource,
}
static errArray cValidate(const xmlDocPtr doc, const xmlSchemaPtr schema) {
xmlLineNumbersDefault(1);
errArray errArr = initErrArray();
struct simpleXmlError simpleError;
Expand Down Expand Up @@ -359,8 +355,6 @@ static errArray cValidateBuf(const void* goXmlSource,
const int goXmlSourceLen,
const short int xmlParserOptions,
const xmlSchemaPtr schema) {
xmlLineNumbersDefault(1);
errArray errArr = initErrArray();
struct simpleXmlError simpleError;
Expand Down

0 comments on commit 6395660

Please sign in to comment.