VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/include/libxml/xmlmemory.h@ 105420

Last change on this file since 105420 was 105420, checked in by vboxsync, 10 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/*
2 * Summary: interface for the memory allocator
3 * Description: provides interfaces for the memory allocator,
4 * including debugging capabilities.
5 *
6 * Copy: See Copyright for the status of this software.
7 *
8 * Author: Daniel Veillard
9 */
10
11
12#ifndef __DEBUG_MEMORY_ALLOC__
13#define __DEBUG_MEMORY_ALLOC__
14
15#include <stdio.h>
16#include <libxml/xmlversion.h>
17
18/**
19 * DEBUG_MEMORY:
20 *
21 * DEBUG_MEMORY replaces the allocator with a collect and debug
22 * shell to the libc allocator.
23 * DEBUG_MEMORY should only be activated when debugging
24 * libxml i.e. if libxml has been configured with --with-debug-mem too.
25 */
26/* #define DEBUG_MEMORY_FREED */
27/* #define DEBUG_MEMORY_LOCATION */
28
29#ifndef VBOX /* Avoid spewing out boring libxml2 memory logging. */
30#ifdef DEBUG
31#ifndef DEBUG_MEMORY
32#define DEBUG_MEMORY
33#endif
34#endif
35#endif /* !VBOX */
36
37/**
38 * DEBUG_MEMORY_LOCATION:
39 *
40 * DEBUG_MEMORY_LOCATION should be activated only when debugging
41 * libxml i.e. if libxml has been configured with --with-debug-mem too.
42 */
43#ifdef DEBUG_MEMORY_LOCATION
44#endif
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*
51 * The XML memory wrapper support 4 basic overloadable functions.
52 */
53/**
54 * xmlFreeFunc:
55 * @mem: an already allocated block of memory
56 *
57 * Signature for a free() implementation.
58 */
59typedef void (*xmlFreeFunc)(void *mem);
60/**
61 * xmlMallocFunc:
62 * @size: the size requested in bytes
63 *
64 * Signature for a malloc() implementation.
65 *
66 * Returns a pointer to the newly allocated block or NULL in case of error.
67 */
68typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) *xmlMallocFunc)(size_t size);
69
70/**
71 * xmlReallocFunc:
72 * @mem: an already allocated block of memory
73 * @size: the new size requested in bytes
74 *
75 * Signature for a realloc() implementation.
76 *
77 * Returns a pointer to the newly reallocated block or NULL in case of error.
78 */
79typedef void *(*xmlReallocFunc)(void *mem, size_t size);
80
81/**
82 * xmlStrdupFunc:
83 * @str: a zero terminated string
84 *
85 * Signature for an strdup() implementation.
86 *
87 * Returns the copy of the string or NULL in case of error.
88 */
89typedef char *(*xmlStrdupFunc)(const char *str);
90
91/*
92 * In general the memory allocation entry points are not kept
93 * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
94 * - xmlMalloc
95 * - xmlMallocAtomic
96 * - xmlRealloc
97 * - xmlMemStrdup
98 * - xmlFree
99 */
100/** DOC_DISABLE */
101#ifdef LIBXML_THREAD_ALLOC_ENABLED
102 #define XML_GLOBALS_ALLOC \
103 XML_OP(xmlMalloc, xmlMallocFunc, XML_NO_ATTR) \
104 XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_NO_ATTR) \
105 XML_OP(xmlRealloc, xmlReallocFunc, XML_NO_ATTR) \
106 XML_OP(xmlFree, xmlFreeFunc, XML_NO_ATTR) \
107 XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_NO_ATTR)
108 #define XML_OP XML_DECLARE_GLOBAL
109 XML_GLOBALS_ALLOC
110 #undef XML_OP
111 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
112 #define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
113 #define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
114 #define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
115 #define xmlFree XML_GLOBAL_MACRO(xmlFree)
116 #define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
117 #endif
118#else
119 #define XML_GLOBALS_ALLOC
120/** DOC_ENABLE */
121 XMLPUBVAR xmlMallocFunc xmlMalloc;
122 XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
123 XMLPUBVAR xmlReallocFunc xmlRealloc;
124 XMLPUBVAR xmlFreeFunc xmlFree;
125 XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
126#endif
127
128/*
129 * The way to overload the existing functions.
130 * The xmlGc function have an extra entry for atomic block
131 * allocations useful for garbage collected memory allocators
132 */
133XMLPUBFUN int
134 xmlMemSetup (xmlFreeFunc freeFunc,
135 xmlMallocFunc mallocFunc,
136 xmlReallocFunc reallocFunc,
137 xmlStrdupFunc strdupFunc);
138XMLPUBFUN int
139 xmlMemGet (xmlFreeFunc *freeFunc,
140 xmlMallocFunc *mallocFunc,
141 xmlReallocFunc *reallocFunc,
142 xmlStrdupFunc *strdupFunc);
143XMLPUBFUN int
144 xmlGcMemSetup (xmlFreeFunc freeFunc,
145 xmlMallocFunc mallocFunc,
146 xmlMallocFunc mallocAtomicFunc,
147 xmlReallocFunc reallocFunc,
148 xmlStrdupFunc strdupFunc);
149XMLPUBFUN int
150 xmlGcMemGet (xmlFreeFunc *freeFunc,
151 xmlMallocFunc *mallocFunc,
152 xmlMallocFunc *mallocAtomicFunc,
153 xmlReallocFunc *reallocFunc,
154 xmlStrdupFunc *strdupFunc);
155
156/*
157 * Initialization of the memory layer.
158 */
159XML_DEPRECATED
160XMLPUBFUN int
161 xmlInitMemory (void);
162
163/*
164 * Cleanup of the memory layer.
165 */
166XML_DEPRECATED
167XMLPUBFUN void
168 xmlCleanupMemory (void);
169/*
170 * These are specific to the XML debug memory wrapper.
171 */
172XMLPUBFUN size_t
173 xmlMemSize (void *ptr);
174XMLPUBFUN int
175 xmlMemUsed (void);
176XMLPUBFUN int
177 xmlMemBlocks (void);
178XML_DEPRECATED
179XMLPUBFUN void
180 xmlMemDisplay (FILE *fp);
181XML_DEPRECATED
182XMLPUBFUN void
183 xmlMemDisplayLast(FILE *fp, long nbBytes);
184XML_DEPRECATED
185XMLPUBFUN void
186 xmlMemShow (FILE *fp, int nr);
187XML_DEPRECATED
188XMLPUBFUN void
189 xmlMemoryDump (void);
190XMLPUBFUN void *
191 xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1);
192XMLPUBFUN void *
193 xmlMemRealloc (void *ptr,size_t size);
194XMLPUBFUN void
195 xmlMemFree (void *ptr);
196XMLPUBFUN char *
197 xmlMemoryStrdup (const char *str);
198XML_DEPRECATED
199XMLPUBFUN void *
200 xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
201XML_DEPRECATED
202XMLPUBFUN void *
203 xmlReallocLoc (void *ptr, size_t size, const char *file, int line);
204XML_DEPRECATED
205XMLPUBFUN void *
206 xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
207XML_DEPRECATED
208XMLPUBFUN char *
209 xmlMemStrdupLoc (const char *str, const char *file, int line);
210
211#ifdef __cplusplus
212}
213#endif /* __cplusplus */
214
215#endif /* __DEBUG_MEMORY_ALLOC__ */
216
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette