@ -142,12 +142,8 @@ xml_is_well_formed(PG_FUNCTION_ARGS)
doctree = xmlParseMemory ( ( char * ) VARDATA ( t ) , docsize ) ;
if ( doctree = = NULL )
{
xmlCleanupParser ( ) ;
PG_RETURN_BOOL ( false ) ; /* i.e. not well-formed */
}
xmlFreeDoc ( doctree ) ;
xmlCleanupParser ( ) ;
PG_RETURN_BOOL ( true ) ;
}
@ -305,7 +301,6 @@ xpath_nodeset(PG_FUNCTION_ARGS)
xpres = pgxml_result_to_text ( pgxml_xpath ( PG_GETARG_TEXT_P ( 0 ) , xpath ) ,
toptag , septag , NULL ) ;
/* xmlCleanupParser(); done by result_to_text routine */
pfree ( xpath ) ;
if ( xpres = = NULL )
@ -340,7 +335,6 @@ xpath_list(PG_FUNCTION_ARGS)
xpres = pgxml_result_to_text ( pgxml_xpath ( PG_GETARG_TEXT_P ( 0 ) , xpath ) ,
NULL , NULL , plainsep ) ;
/* xmlCleanupParser(); done by result_to_text routine */
pfree ( xpath ) ;
if ( xpres = = NULL )
@ -379,7 +373,6 @@ xpath_string(PG_FUNCTION_ARGS)
xpres = pgxml_result_to_text ( pgxml_xpath ( PG_GETARG_TEXT_P ( 0 ) , xpath ) ,
NULL , NULL , NULL ) ;
xmlCleanupParser ( ) ;
pfree ( xpath ) ;
if ( xpres = = NULL )
@ -411,13 +404,10 @@ xpath_number(PG_FUNCTION_ARGS)
pfree ( xpath ) ;
if ( res = = NULL )
{
xmlCleanupParser ( ) ;
PG_RETURN_NULL ( ) ;
}
fRes = xmlXPathCastToNumber ( res ) ;
xmlCleanupParser ( ) ;
if ( xmlXPathIsNaN ( fRes ) )
PG_RETURN_NULL ( ) ;
@ -448,13 +438,10 @@ xpath_bool(PG_FUNCTION_ARGS)
pfree ( xpath ) ;
if ( res = = NULL )
{
xmlCleanupParser ( ) ;
PG_RETURN_BOOL ( false ) ;
}
bRes = xmlXPathCastToBoolean ( res ) ;
xmlCleanupParser ( ) ;
PG_RETURN_BOOL ( bRes ) ;
}
@ -477,9 +464,7 @@ pgxml_xpath(text *document, xmlChar *xpath)
doctree = xmlParseMemory ( ( char * ) VARDATA ( document ) , docsize ) ;
if ( doctree = = NULL )
{ /* not well-formed */
return NULL ;
}
return NULL ; /* not well-formed */
ctxt = xmlXPathNewContext ( doctree ) ;
ctxt - > node = xmlDocGetRootElement ( doctree ) ;
@ -488,7 +473,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
comppath = xmlXPathCompile ( xpath ) ;
if ( comppath = = NULL )
{
xmlCleanupParser ( ) ;
xmlFreeDoc ( doctree ) ;
elog_error ( " XPath Syntax Error " , true ) ;
}
@ -500,7 +484,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
if ( res = = NULL )
{
xmlXPathFreeContext ( ctxt ) ;
/* xmlCleanupParser(); */
xmlFreeDoc ( doctree ) ;
return NULL ;
@ -520,10 +503,8 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
text * xpres ;
if ( res = = NULL )
{
xmlCleanupParser ( ) ;
return NULL ;
}
switch ( res - > type )
{
case XPATH_NODESET :
@ -548,9 +529,6 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
VARATT_SIZEP ( xpres ) = ressize + VARHDRSZ ;
/* Free various storage */
xmlCleanupParser ( ) ;
/* xmlFreeDoc(doctree); -- will die at end of tuple anyway */
xmlFree ( xpresstr ) ;
elog_error ( " XPath error " , false ) ;
@ -789,7 +767,6 @@ xpath_table(PG_FUNCTION_ARGS)
comppath = xmlXPathCompile ( xpaths [ j ] ) ;
if ( comppath = = NULL )
{
xmlCleanupParser ( ) ;
xmlFreeDoc ( doctree ) ;
elog_error ( " XPath Syntax Error " , true ) ;
}
@ -854,8 +831,6 @@ xpath_table(PG_FUNCTION_ARGS)
pfree ( xmldoc ) ;
}
xmlCleanupParser ( ) ;
tuplestore_donestoring ( tupstore ) ;
SPI_finish ( ) ;