1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

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: * htmlInitAutoClose:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* This is a no-op now. * This is a no-op now.
*/ */
void void

6
SAX2.c
View File

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

9
dict.c
View File

@ -146,8 +146,10 @@ static unsigned int rand_seed = 0;
/** /**
* xmlInitializeDict: * xmlInitializeDict:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Do the dictionary mutex initialization. * Do the dictionary mutex initialization.
* this function is deprecated
* *
* Returns 0 if initialization was already done, and 1 if that * Returns 0 if initialization was already done, and 1 if that
* call led to the initialization * call led to the initialization
@ -210,6 +212,11 @@ int __xmlRandom(void) {
/** /**
* xmlDictCleanup: * 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 * Free the dictionary mutex. Do not call unless sure the library
* is not in use anymore ! * is not in use anymore !
*/ */

View File

@ -1408,6 +1408,9 @@ xmlNewCharEncodingHandler(const char *name,
/** /**
* xmlInitCharEncodingHandlers: * xmlInitCharEncodingHandlers:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the char encoding support, it registers the default * Initialize the char encoding support, it registers the default
* encoding supported. * encoding supported.
* NOTE: while public, this function usually doesn't need to be called * NOTE: while public, this function usually doesn't need to be called
@ -1468,6 +1471,11 @@ xmlInitCharEncodingHandlers(void) {
/** /**
* xmlCleanupCharEncodingHandlers: * 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 * Cleanup the memory allocated for the char encoding support, it
* unregisters all the encoding handlers and the aliases. * unregisters all the encoding handlers and the aliases.
*/ */

View File

@ -40,6 +40,9 @@ static xmlMutexPtr xmlThrDefMutex = NULL;
/** /**
* xmlInitGlobals: * xmlInitGlobals:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Additional initialisation for multi-threading * Additional initialisation for multi-threading
*/ */
void xmlInitGlobals(void) void xmlInitGlobals(void)
@ -522,6 +525,11 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
/** /**
* xmlCleanupGlobals: * 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 * Additional cleanup for multi-threading
*/ */
void xmlCleanupGlobals(void) void xmlCleanupGlobals(void)

View File

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

View File

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

View File

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

View File

@ -24,7 +24,9 @@
extern "C" { extern "C" {
#endif #endif
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlInitGlobals(void); XMLPUBFUN void XMLCALL xmlInitGlobals(void);
XML_DEPRECATED
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); 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. * Actually comes from the HTML parser but launched from the init stuff.
*/ */
XML_DEPRECATED
XMLPUBFUN void XMLCALL htmlInitAutoClose (void); XMLPUBFUN void XMLCALL htmlInitAutoClose (void);
XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename, XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename,
const char *encoding); const char *encoding);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2815,6 +2815,9 @@ xmlRelaxNGRegisterTypeLibrary(const xmlChar * namespace, void *data,
/** /**
* xmlRelaxNGInitTypes: * xmlRelaxNGInitTypes:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default type libraries. * Initialize the default type libraries.
* *
* Returns 0 in case of success and -1 in case of error. * Returns 0 in case of success and -1 in case of error.
@ -2849,6 +2852,11 @@ xmlRelaxNGInitTypes(void)
/** /**
* xmlRelaxNGCleanupTypes: * 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 * Cleanup the default Schemas type library associated to RelaxNG
*/ */
void void

View File

@ -843,6 +843,9 @@ xmlUnlockLibrary(void)
/** /**
* xmlInitThreads: * xmlInitThreads:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* xmlInitThreads() is used to to initialize all the thread related * xmlInitThreads() is used to to initialize all the thread related
* data of the libxml2 library. * data of the libxml2 library.
*/ */
@ -883,6 +886,11 @@ xmlInitThreads(void)
/** /**
* xmlCleanupThreads: * 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 * xmlCleanupThreads() is used to to cleanup all the thread related
* data of the libxml2 library once processing has ended. * data of the libxml2 library once processing has ended.
* *

View File

@ -935,6 +935,9 @@ xmlMemoryDump(void)
/** /**
* xmlInitMemory: * xmlInitMemory:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the memory layer. * Initialize the memory layer.
* *
* Returns 0 on success * Returns 0 on success
@ -974,6 +977,11 @@ xmlInitMemory(void)
/** /**
* xmlCleanupMemory: * 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 * Free up all the memory allocated by the library for its own
* use. This should not be called by user level code. * use. This should not be called by user level code.
*/ */

View File

@ -386,6 +386,9 @@ xmlSchemaAddParticle(void)
/* /*
* xmlSchemaInitTypes: * xmlSchemaInitTypes:
* *
* DEPRECATED: This function will be made private. Call xmlInitParser to
* initialize the library.
*
* Initialize the default XML Schemas type library * Initialize the default XML Schemas type library
*/ */
void void
@ -623,6 +626,11 @@ xmlSchemaFreeTypeEntry(void *type, const xmlChar *name ATTRIBUTE_UNUSED) {
/** /**
* xmlSchemaCleanupTypes: * 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 * Cleanup the default XML Schemas type library
*/ */
void void

View File

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