aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-04-19 00:07:51 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-04-19 00:07:51 +0000
commit3c908dca479ed50dca24b8593bca90e40dbde6b8 (patch)
tree6857a13f7d045a5f0880b97a02484ba4e3c8b7bc /include
parent8494271318577f3dc3d8a4cce298314f2f330cc5 (diff)
downloadandroid_external_libxml2-3c908dca479ed50dca24b8593bca90e40dbde6b8.tar.gz
android_external_libxml2-3c908dca479ed50dca24b8593bca90e40dbde6b8.tar.bz2
android_external_libxml2-3c908dca479ed50dca24b8593bca90e40dbde6b8.zip
added xmlMallocAtomic() to be used when allocating blocks which do not
* DOCBparser.c HTMLparser.c c14n.c catalog.c encoding.c globals.c nanohttp.c parser.c parserInternals.c relaxng.c tree.c uri.c xmlmemory.c xmlreader.c xmlregexp.c xpath.c xpointer.c include/libxml/globals.h include/libxml/xmlmemory.h: added xmlMallocAtomic() to be used when allocating blocks which do not contains pointers, add xmlGcMemSetup() and xmlGcMemGet() to allow registering the full set of functions needed by a garbage collecting allocator like libgc, ref #109944 Daniel
Diffstat (limited to 'include')
-rw-r--r--include/libxml/globals.h14
-rw-r--r--include/libxml/xmlmemory.h23
2 files changed, 37 insertions, 0 deletions
diff --git a/include/libxml/globals.h b/include/libxml/globals.h
index 6f880c08..9a7e3d1b 100644
--- a/include/libxml/globals.h
+++ b/include/libxml/globals.h
@@ -45,6 +45,7 @@ extern "C" {
#undef xmlLineNumbersDefaultValue
#undef xmlLoadExtDtdDefaultValue
#undef xmlMalloc
+#undef xmlMallocAtomic
#undef xmlMemStrdup
#undef xmlParserDebugEntities
#undef xmlParserVersion
@@ -97,6 +98,8 @@ struct _xmlGlobalState
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
+
+ xmlMallocFunc xmlMallocAtomic;
};
#ifdef __cplusplus
@@ -116,6 +119,7 @@ xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
* 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
@@ -131,6 +135,14 @@ LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
#endif
#ifdef LIBXML_THREAD_ENABLED
+extern xmlMallocFunc *__xmlMallocAtomic(void);
+#define xmlMallocAtomic \
+(*(__xmlMallocAtomic()))
+#else
+LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
+#endif
+
+#ifdef LIBXML_THREAD_ENABLED
extern xmlReallocFunc *__xmlRealloc(void);
#define xmlRealloc \
(*(__xmlRealloc()))
@@ -153,8 +165,10 @@ extern xmlStrdupFunc *__xmlMemStrdup(void);
#else
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
#endif
+
#else /* !LIBXML_THREAD_ALLOC_ENABLED */
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
+LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
diff --git a/include/libxml/xmlmemory.h b/include/libxml/xmlmemory.h
index 8e8df944..f35ffffb 100644
--- a/include/libxml/xmlmemory.h
+++ b/include/libxml/xmlmemory.h
@@ -86,12 +86,15 @@ typedef char *(*xmlStrdupFunc)(const char *str);
* The 4 interfaces used for all memory handling within libxml.
LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
+LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
*/
/*
* The way to overload the existing functions.
+ * The xmlGc function have an extra entry for atomic block
+ * allocations useful for garbage collected memory allocators
*/
int xmlMemSetup (xmlFreeFunc freeFunc,
xmlMallocFunc mallocFunc,
@@ -101,6 +104,16 @@ int xmlMemGet (xmlFreeFunc *freeFunc,
xmlMallocFunc *mallocFunc,
xmlReallocFunc *reallocFunc,
xmlStrdupFunc *strdupFunc);
+int xmlGcMemSetup (xmlFreeFunc freeFunc,
+ xmlMallocFunc mallocFunc,
+ xmlMallocFunc mallocAtomicFunc,
+ xmlReallocFunc reallocFunc,
+ xmlStrdupFunc strdupFunc);
+int xmlGcMemGet (xmlFreeFunc *freeFunc,
+ xmlMallocFunc *mallocFunc,
+ xmlMallocFunc *mallocAtomicFunc,
+ xmlReallocFunc *reallocFunc,
+ xmlStrdupFunc *strdupFunc);
/*
* Initialization of the memory layer.
@@ -130,6 +143,16 @@ char * xmlMemoryStrdup (const char *str);
*/
#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)
/**
+ * xmlMallocAtomic:
+ * @size: number of bytes to allocate
+ *
+ * Wrapper for the malloc() function used in the XML library for allocation
+ * of block not containing pointers to other areas.
+ *
+ * Returns the pointer to the allocated area or NULL in case of error.
+ */
+#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)
+/**
* xmlRealloc:
* @ptr: pointer to the existing allocated area
* @size: number of bytes to allocate