mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-25 10:50:08 +03:00
globals: Move malloc hooks back to xmlmemory.h
This commit is contained in:
parent
a77f9ab84c
commit
d1336fd393
@ -80,6 +80,7 @@ struct _xmlGlobalState {
|
||||
|
||||
#define XML_OP XML_DECLARE_MEMBER
|
||||
XML_GLOBALS
|
||||
XML_GLOBALS_ALLOC
|
||||
#undef XML_OP
|
||||
};
|
||||
|
||||
@ -1136,6 +1137,7 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun
|
||||
|
||||
#define XML_OP XML_DEFINE_GLOBAL_WRAPPER
|
||||
XML_GLOBALS
|
||||
XML_GLOBALS_ALLOC
|
||||
#undef XML_OP
|
||||
|
||||
/* For backward compatibility */
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -86,8 +85,6 @@ xmlDllMain(void *hinstDLL, unsigned long fdwReason,
|
||||
|
||||
/* Declare globals with macro magic */
|
||||
|
||||
#define XML_EMPTY
|
||||
|
||||
#define XML_GLOBALS_CORE \
|
||||
/* error handling */ \
|
||||
XML_OP(xmlLastError, xmlError, XML_DEPRECATED) \
|
||||
@ -128,52 +125,15 @@ xmlDllMain(void *hinstDLL, unsigned long fdwReason,
|
||||
#define XML_GLOBALS_HTML
|
||||
#endif
|
||||
|
||||
/*
|
||||
* In general the memory allocation entry points are not kept
|
||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||
* - xmlMalloc
|
||||
* - xmlMallocAtomic
|
||||
* - xmlRealloc
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#define XML_GLOBALS_ALLOC \
|
||||
XML_OP(xmlMalloc, xmlMallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlRealloc, xmlReallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlFree, xmlFreeFunc, XML_EMPTY) \
|
||||
XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_EMPTY)
|
||||
#else
|
||||
#define XML_GLOBALS_ALLOC
|
||||
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif
|
||||
|
||||
#define XML_GLOBALS \
|
||||
XML_GLOBALS_CORE \
|
||||
XML_GLOBALS_HTML \
|
||||
XML_GLOBALS_ALLOC
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBFUN type *__##name(void);
|
||||
#else
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBVAR type name;
|
||||
#endif
|
||||
XML_GLOBALS_HTML
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define XML_GLOBAL_MACRO(name) (*__##name())
|
||||
|
||||
#define xmlLastError XML_GLOBAL_MACRO(xmlLastError)
|
||||
#define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
|
||||
#define xmlBufferAllocScheme XML_GLOBAL_MACRO(xmlBufferAllocScheme)
|
||||
@ -212,14 +172,6 @@ XML_GLOBALS
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
#define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
|
||||
#define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
|
||||
#define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
|
||||
#define xmlFree XML_GLOBAL_MACRO(xmlFree)
|
||||
#define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <libxml/entities.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -7,8 +7,6 @@
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifndef __XML_ERROR_H__
|
||||
#define __XML_ERROR_H__
|
||||
|
||||
@ -892,10 +890,11 @@ XMLPUBFUN void
|
||||
xmlParserValidityWarning (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
struct _xmlParserInput;
|
||||
XMLPUBFUN void
|
||||
xmlParserPrintFileInfo (xmlParserInputPtr input);
|
||||
xmlParserPrintFileInfo (struct _xmlParserInput *input);
|
||||
XMLPUBFUN void
|
||||
xmlParserPrintFileContext (xmlParserInputPtr input);
|
||||
xmlParserPrintFileContext (struct _xmlParserInput *input);
|
||||
|
||||
/*
|
||||
* Extended error information routines
|
||||
|
@ -61,13 +61,39 @@ typedef void *(*xmlReallocFunc)(void *mem, size_t size);
|
||||
typedef char *(*xmlStrdupFunc)(const char *str);
|
||||
|
||||
/*
|
||||
* The 4 interfaces used for all memory handling within libxml.
|
||||
LIBXML_DLL_IMPORT xmlFreeFunc xmlFree;
|
||||
LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;
|
||||
LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;
|
||||
LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;
|
||||
LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;
|
||||
* In general the memory allocation entry points are not kept
|
||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||
* - xmlMalloc
|
||||
* - xmlMallocAtomic
|
||||
* - xmlRealloc
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#define XML_GLOBALS_ALLOC \
|
||||
XML_OP(xmlMalloc, xmlMallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlRealloc, xmlReallocFunc, XML_EMPTY) \
|
||||
XML_OP(xmlFree, xmlFreeFunc, XML_EMPTY) \
|
||||
XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_EMPTY)
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_ALLOC
|
||||
#undef XML_OP
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
|
||||
#define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
|
||||
#define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
|
||||
#define xmlFree XML_GLOBAL_MACRO(xmlFree)
|
||||
#define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
|
||||
#endif
|
||||
#else
|
||||
#define XML_GLOBALS_ALLOC
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The way to overload the existing functions.
|
||||
@ -191,12 +217,5 @@ XMLPUBFUN char *
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef __XML_GLOBALS_H
|
||||
#ifndef __XML_THREADS_H__
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __DEBUG_MEMORY_ALLOC__ */
|
||||
|
||||
|
@ -524,6 +524,17 @@ XMLPUBFUN void xmlCheckVersion(int version);
|
||||
#endif
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#define XML_EMPTY
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBFUN type *__##name(void);
|
||||
#define XML_GLOBAL_MACRO(name) (*__##name())
|
||||
#else
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBVAR type name;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -24,9 +24,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <libxml/globals.h> /* must come before xmlmemory.h */
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/threads.h>
|
||||
|
||||
#include "private/memory.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user