Deprecate module init and cleanup functions

These functions shouldn't be part of the public API. Most init
functions are only thread-safe when called from xmlInitParser. Global
variables should only be cleaned up by calling xmlCleanupParser.
This commit is contained in:
Nick Wellnhofer 2022-03-06 13:55:48 +01:00
parent 7d02c7291f
commit 40483d0ce2
21 changed files with 100 additions and 1 deletions

View File

@ -1394,6 +1394,9 @@ static const elementPriority htmlEndPriority[] = {
/**
* htmlInitAutoClose:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* This is a no-op now.
*/
void

6
SAX2.c
View File

@ -2928,6 +2928,9 @@ xmlSAX2InitDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
/**
* xmlDefaultSAXHandlerInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default SAX2 handler
*/
void
@ -2986,6 +2989,9 @@ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr)
/**
* htmlDefaultSAXHandlerInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default SAX handler
*/
void

9
dict.c
View File

@ -146,8 +146,10 @@ static unsigned int rand_seed = 0;
/**
* xmlInitializeDict:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Do the dictionary mutex initialization.
* this function is deprecated
*
* Returns 0 if initialization was already done, and 1 if that
* call led to the initialization
@ -210,6 +212,11 @@ int __xmlRandom(void) {
/**
* xmlDictCleanup:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Free the dictionary mutex. Do not call unless sure the library
* is not in use anymore !
*/

View File

@ -1408,6 +1408,9 @@ xmlNewCharEncodingHandler(const char *name,
/**
* xmlInitCharEncodingHandlers:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the char encoding support, it registers the default
* encoding supported.
* NOTE: while public, this function usually doesn't need to be called
@ -1468,6 +1471,11 @@ xmlInitCharEncodingHandlers(void) {
/**
* xmlCleanupCharEncodingHandlers:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the memory allocated for the char encoding support, it
* unregisters all the encoding handlers and the aliases.
*/

View File

@ -40,6 +40,9 @@ static xmlMutexPtr xmlThrDefMutex = NULL;
/**
* xmlInitGlobals:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Additional initialisation for multi-threading
*/
void xmlInitGlobals(void)
@ -522,6 +525,11 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
/**
* xmlCleanupGlobals:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Additional cleanup for multi-threading
*/
void xmlCleanupGlobals(void)

View File

@ -159,9 +159,11 @@ XMLPUBFUN void XMLCALL
#ifdef LIBXML_HTML_ENABLED
XMLPUBFUN void XMLCALL
xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
htmlDefaultSAXHandlerInit (void);
#endif
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlDefaultSAXHandlerInit (void);
#ifdef __cplusplus

View File

@ -27,6 +27,7 @@ typedef xmlDict *xmlDictPtr;
/*
* Initializer
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL xmlInitializeDict(void);
/*
@ -70,6 +71,7 @@ XMLPUBFUN int XMLCALL
/*
* Cleanup function
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlDictCleanup (void);

View File

@ -153,8 +153,10 @@ extern "C" {
/*
* Interfaces for encoding handlers.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlInitCharEncodingHandlers (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupCharEncodingHandlers (void);
XMLPUBFUN void XMLCALL

View File

@ -24,7 +24,9 @@
extern "C" {
#endif
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlInitGlobals(void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
/**

View File

@ -574,6 +574,7 @@ XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in);
/*
* Actually comes from the HTML parser but launched from the init stuff.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL htmlInitAutoClose (void);
XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename,
const char *encoding);

View File

@ -116,8 +116,10 @@ typedef enum {
XML_RELAXNGP_CRNG = 2
} xmlRelaxNGParserFlag;
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlRelaxNGInitTypes (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlRelaxNGCleanupTypes (void);

View File

@ -57,6 +57,7 @@ XMLPUBFUN void XMLCALL
/*
* Library wide APIs.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlInitThreads (void);
XMLPUBFUN void XMLCALL
@ -67,6 +68,7 @@ XMLPUBFUN int XMLCALL
xmlGetThreadId (void);
XMLPUBFUN int XMLCALL
xmlIsMainThread (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupThreads(void);
XMLPUBFUN xmlGlobalStatePtr XMLCALL

View File

@ -126,12 +126,14 @@ XMLPUBFUN int XMLCALL
/*
* Initialization of the memory layer.
*/
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlInitMemory (void);
/*
* Cleanup of the memory layer.
*/
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlCleanupMemory (void);
/*

View File

@ -30,8 +30,10 @@ typedef enum {
XML_SCHEMA_WHITESPACE_COLLAPSE = 3
} xmlSchemaWhitespaceValueType;
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlSchemaInitTypes (void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlSchemaCleanupTypes (void);
XMLPUBFUN xmlSchemaTypePtr XMLCALL

View File

@ -549,6 +549,7 @@ XMLPUBFUN void XMLCALL
xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp);
#endif /* LIBXML_XPATH_ENABLED */
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPathInit (void);
XMLPUBFUN int XMLCALL

View File

@ -289,8 +289,22 @@ skip_impl = (
)
deprecated_funcs = {
'htmlDefaultSAXHandlerInit': True,
'htmlInitAutoClose': True,
'xmlCleanupCharEncodingHandlers': True,
'xmlCleanupGlobals': True,
'xmlDefaultSAXHandlerInit': True,
'xmlDictCleanup': True,
'xmlInitCharEncodingHandlers': True,
'xmlInitGlobals': True,
'xmlInitializeDict': True,
'xmlIsRef': True,
'xmlRelaxNGCleanupTypes': True,
'xmlRelaxNGInitTypes': True,
'xmlRemoveRef': True,
'xmlSchemaCleanupTypes': True,
'xmlSchemaInitTypes': True,
'xmlXPathInit': True,
}
def skip_function(name):

View File

@ -2815,6 +2815,9 @@ xmlRelaxNGRegisterTypeLibrary(const xmlChar * namespace, void *data,
/**
* xmlRelaxNGInitTypes:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default type libraries.
*
* Returns 0 in case of success and -1 in case of error.
@ -2849,6 +2852,11 @@ xmlRelaxNGInitTypes(void)
/**
* xmlRelaxNGCleanupTypes:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the default Schemas type library associated to RelaxNG
*/
void

View File

@ -843,6 +843,9 @@ xmlUnlockLibrary(void)
/**
* xmlInitThreads:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* xmlInitThreads() is used to to initialize all the thread related
* data of the libxml2 library.
*/
@ -883,6 +886,11 @@ xmlInitThreads(void)
/**
* xmlCleanupThreads:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* xmlCleanupThreads() is used to to cleanup all the thread related
* data of the libxml2 library once processing has ended.
*

View File

@ -935,6 +935,9 @@ xmlMemoryDump(void)
/**
* xmlInitMemory:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the memory layer.
*
* Returns 0 on success
@ -974,6 +977,11 @@ xmlInitMemory(void)
/**
* xmlCleanupMemory:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Free up all the memory allocated by the library for its own
* use. This should not be called by user level code.
*/

View File

@ -386,6 +386,9 @@ xmlSchemaAddParticle(void)
/*
* xmlSchemaInitTypes:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default XML Schemas type library
*/
void
@ -623,6 +626,11 @@ xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
/**
* xmlSchemaCleanupTypes:
*
* DEPRECATED: This function will be made private. Call xmlCleanupParser
* to free global state but see the warnings there. xmlCleanupParser
* should be only called once at program exit. In most cases, you don't
* have call cleanup functions at all.
*
* Cleanup the default XML Schemas type library
*/
void

View File

@ -482,6 +482,9 @@ double xmlXPathNINF;
/**
* xmlXPathInit:
*
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the XPath environment
*/
ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")