1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-08-08 21:42:07 +03:00

applied changes from Tom Moog #58002 Some cleanup, there is still a memory

* libxslt/transform.[ch]: applied changes from Tom Moog #58002
* libexslt/functions.c libxslt/documents.c libxslt/extensions.c:
  Some cleanup, there is still a memory leak left and some warnings
  in libexslt.
Daniel
This commit is contained in:
Daniel Veillard
2001-07-26 21:30:29 +00:00
parent ef9ed9d048
commit cca684b247
6 changed files with 74 additions and 15 deletions

View File

@@ -1,3 +1,10 @@
Fri Jul 27 10:50:39 EDT 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/transform.[ch]: applied changes from Tom Moog #58002
* libexslt/functions.c libxslt/documents.c libxslt/extensions.c:
Some cleanup, there is still a memory leak left and some warnings
in libexslt.
Thu Jul 26 19:05:48 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
* libxslt/extensions.[ch] libxslt/functions.[ch] libxslt/preproc.c

View File

@@ -1,3 +1,5 @@
#include <string.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

View File

@@ -238,8 +238,8 @@ xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) {
return(ret);
ret = ret->next;
}
if (doc==ctxt->style->doc)
return ctxt->style;
if (doc == ctxt->style->doc)
return(ctxt->document);
return(NULL);
}

View File

@@ -1113,7 +1113,8 @@ xsltExtModuleTopLevelLookup (const xmlChar *name, const xmlChar *URI) {
if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
return(NULL);
return xmlHashLookup2(xsltTopLevelsHash, name, URI);
return((xsltPreComputeFunction)
xmlHashLookup2(xsltTopLevelsHash, name, URI));
}
/**
@@ -1158,10 +1159,10 @@ static xmlChar *testStyleData = NULL;
* function libxslt:test() for testing the extensions support.
*/
static void
xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs)
xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs ATTRIBUTE_UNUSED)
{
xsltTransformContextPtr tctxt;
void *data;
void *data = NULL;
tctxt = xsltXPathGetTransformContext(ctxt);
@@ -1370,7 +1371,8 @@ xsltExtShutdownTest(xsltTransformContextPtr ctxt,
* Returns a pointer to the module specific data for this transformation
*/
static void *
xsltExtStyleInitTest(xsltStylesheetPtr style, const xmlChar * URI)
xsltExtStyleInitTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
const xmlChar * URI)
{
if (testStyleData != NULL) {
xsltPrintErrorContext(NULL, NULL, NULL);
@@ -1394,7 +1396,7 @@ xsltExtStyleInitTest(xsltStylesheetPtr style, const xmlChar * URI)
* A function called at shutdown time of an XSLT extension module
*/
static void
xsltExtStyleShutdownTest(xsltStylesheetPtr style,
xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
const xmlChar * URI, void *data) {
if (testStyleData == NULL) {
xsltGenericError(xsltGenericErrorContext,

View File

@@ -164,7 +164,7 @@ xsltGetXIncludeDefault(void) {
*
* Returns the newly allocated xsltTransformContextPtr or NULL in case of error
*/
static xsltTransformContextPtr
xsltTransformContextPtr
xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
xsltTransformContextPtr cur;
xsltDocumentPtr docu;
@@ -259,7 +259,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
*
* Free up the memory allocated by @ctxt
*/
static void
void
xsltFreeTransformContext(xsltTransformContextPtr ctxt) {
if (ctxt == NULL)
return;
@@ -3117,6 +3117,7 @@ xsltGetHTMLIDs(const xmlChar *version, const xmlChar **public,
* @params: a NULL terminated arry of parameters names/values tuples
* @output: the targetted output
* @profile: profile FILE * output or NULL
* @user: user provided parameter
*
* Apply the stylesheet to the document
* NOTE: This may lead to a non-wellformed output XML wise !
@@ -3126,7 +3127,7 @@ xsltGetHTMLIDs(const xmlChar *version, const xmlChar **public,
static xmlDocPtr
xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
const char **params, const char *output,
FILE * profile)
FILE * profile, xsltTransformContextPtr userCtxt)
{
xmlDocPtr res = NULL;
xsltTransformContextPtr ctxt = NULL;
@@ -3140,7 +3141,12 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
if ((style == NULL) || (doc == NULL))
return (NULL);
if (userCtxt != NULL)
ctxt = userCtxt;
else
ctxt = xsltNewTransformContext(style, doc);
if (ctxt == NULL)
return (NULL);
@@ -3311,7 +3317,9 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
if (profile != NULL) {
xsltSaveProfiling(ctxt, profile);
}
if (userCtxt == NULL)
xsltFreeTransformContext(ctxt);
return (res);
error:
@@ -3337,7 +3345,7 @@ xmlDocPtr
xsltApplyStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
const char **params)
{
return (xsltApplyStylesheetInternal(style, doc, params, NULL, NULL));
return (xsltApplyStylesheetInternal(style, doc, params, NULL, NULL, NULL));
}
/**
@@ -3358,7 +3366,33 @@ xsltProfileStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
{
xmlDocPtr res;
res = xsltApplyStylesheetInternal(style, doc, params, NULL, output);
res = xsltApplyStylesheetInternal(style, doc, params, NULL, output, NULL);
return (res);
}
/**
* xsltApplyStylesheetUser:
* @style: a parsed XSLT stylesheet
* @doc: a parsed XML document
* @params: a NULL terminated arry of parameters names/values tuples
* @output: the targetted output
* @profile: profile FILE * output or NULL
* @userCtxt: user provided transform context
*
* Apply the stylesheet to the document and allow the user to provide
* its own transformation context.
*
* Returns the result document or NULL in case of error
*/
xmlDocPtr
xsltApplyStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc,
const char **params, const char *output,
FILE * profile, xsltTransformContextPtr userCtxt)
{
xmlDocPtr res;
res = xsltApplyStylesheetInternal(style, doc, params, output,
profile, userCtxt);
return (res);
}
@@ -3405,7 +3439,7 @@ xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
return (-1);
}
tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL);
tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL, NULL);
if (tmp == NULL) {
xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,

View File

@@ -23,6 +23,20 @@ extern "C" {
void xsltSetXIncludeDefault (int xinclude);
int xsltGetXIncludeDefault (void);
/**
* Export context to users.
*/
xsltTransformContextPtr xsltNewTransformContext (xsltStylesheetPtr style,
xmlDocPtr doc);
void xsltFreeTransformContext(xsltTransformContextPtr ctxt);
xmlDocPtr xsltApplyStylesheetUser (xsltStylesheetPtr style,
xmlDocPtr doc,
const char **params,
const char *output,
FILE * profile,
xsltTransformContextPtr userCtxt);
/**
* Private Interfaces
*/