1 * Summary: interface for the memory allocator
2 * Description: provides interfaces for the memory allocator,
3 * including debugging capabilities.
5 * Copy: See Copyright for the status of this software.
7 * Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
9 /if not defined(DEBUG_MEMORY_ALLOC__)
10 /define DEBUG_MEMORY_ALLOC__
12 /include "libxmlrpg/xmlversion"
13 /include "libxmlrpg/xmlTypesC"
17 * DEBUG_MEMORY replaces the allocator with a collect and debug
18 * shell to the libc allocator.
19 * DEBUG_MEMORY should only be activated when debugging
20 * libxml i.e. if libxml has been configured with --with-debug-mem too.
22 * /define DEBUG_MEMORY_FREED
23 * /define DEBUG_MEMORY_LOCATION
26 /if not defined(DEBUG_MEMORY)
31 * DEBUG_MEMORY_LOCATION:
33 * DEBUG_MEMORY_LOCATION should be activated only when debugging
34 * libxml i.e. if libxml has been configured with --with-debug-mem too.
36 /if defined(DEBUG_MEMORY_LOCATION)
39 * The XML memory wrapper support 4 basic overloadable functions.
42 * @mem: an already allocated block of memory
44 * Signature for a free() implementation.
46 d xmlFreeFunc s * based(######typedef######)
50 * @size: the size requested in bytes
52 * Signature for a malloc() implementation.
54 * Returns a pointer to the newly allocated block or NULL in case of error.
56 d xmlMallocFunc s * based(######typedef######)
60 * @mem: an already allocated block of memory
61 * @size: the new size requested in bytes
63 * Signature for a realloc() implementation.
65 * Returns a pointer to the newly reallocated block or NULL in case of error.
67 d xmlReallocFunc s * based(######typedef######)
71 * @str: a zero terminated string
73 * Signature for an strdup() implementation.
75 * Returns the copy of the string or NULL in case of error.
77 d xmlStrdupFunc s * based(######typedef######)
80 * The 5 interfaces used for all memory handling within libxml.
81 * Since indirect calls are only supported via a based prototype,
82 * storage is accessed via functions.
84 d get_xmlFree pr extproc('__get_xmlFree')
87 d set_xmlFree pr extproc('__set_xmlFree')
88 d func value like(xmlFreeFunc)
90 d xmlFree pr extproc('__call_xmlFree')
93 d get_xmlMalloc pr extproc('__get_xmlMalloc')
96 d set_xmlMalloc pr extproc('__set_xmlMalloc')
97 d func value like(xmlMallocFunc)
99 d xmlMalloc pr * extproc('__call_xmlMalloc') void *
100 d size value like(xmlCsize_t)
102 d get_xmlMallocAtomic...
103 d pr extproc('__get_xmlMallocAtomic')
104 d like(xmlMallocFunc)
106 d set_xmlMallocAtomic...
107 d pr extproc('__set_xmlMallocAtomic')
108 d func value like(xmlMallocFunc)
111 d pr * extproc('__call_xmlMallocAtomic') void *
112 d size value like(xmlCsize_t)
114 d get_xmlRealloc pr extproc('__get_xmlRealloc')
115 d like(xmlReallocFunc)
117 d set_xmlRealloc pr extproc('__set_xmlRealloc')
118 d func value like(xmlReallocFunc)
120 d xmlRealloc pr * extproc('__call_xmlRealloc') void *
122 d size value like(xmlCsize_t)
124 d get_xmlMemStrdup...
125 d pr extproc('__get_xmlMemStrdup')
126 d like(xmlStrdupFunc)
128 d set_xmlMemStrdup...
129 d pr extproc('__set_xmlMemstrdup')
130 d func value like(xmlStrdupFunc)
132 d xmlMemStrdup pr * extproc('__call_xmlMemStrdup') void *
133 d str * value options(*string) const char *
135 * The way to overload the existing functions.
136 * The xmlGc function have an extra entry for atomic block
137 * allocations useful for garbage collected memory allocators
139 d xmlMemSetup pr extproc('xmlMemSetup')
141 d freeFunc value like(xmlFreeFunc)
142 d mallocFunc value like(xmlMallocFunc)
143 d reallocFunc value like(xmlReallocFunc)
144 d strdupFunc value like(xmlStrdupFunc)
146 d xmlMemGet pr extproc('xmlMemGet')
148 d freeFunc like(xmlFreeFunc)
149 d mallocFunc like(xmlMallocFunc)
150 d reallocFunc like(xmlReallocFunc)
151 d strdupFunc like(xmlStrdupFunc)
153 d xmlGcMemSetup pr extproc('xmlGcMemSetup')
155 d freeFunc value like(xmlFreeFunc)
156 d mallocFunc value like(xmlMallocFunc)
157 d mallocAtomicFunc...
158 d value like(xmlMallocFunc)
159 d reallocFunc value like(xmlReallocFunc)
160 d strdupFunc value like(xmlStrdupFunc)
162 d xmlGcMemGet pr extproc('xmlGcMemGet')
164 d freeFunc like(xmlFreeFunc)
165 d mallocFunc like(xmlMallocFunc)
166 d mallocAtomicFunc...
167 d like(xmlMallocFunc)
168 d reallocFunc like(xmlReallocFunc)
169 d strdupFunc like(xmlStrdupFunc)
171 * Initialization of the memory layer.
173 d xmlInitMemory pr extproc('xmlInitMemory')
176 * Cleanup of the memory layer.
178 d xmlCleanupMemory...
179 d pr extproc('xmlCleanupMemory')
181 * These are specific to the XML debug memory wrapper.
183 d xmlMemUsed pr extproc('xmlMemUsed')
186 d xmlMemBlocks pr extproc('xmlMemBlocks')
189 d xmlMemDisplay pr extproc('xmlMemDisplay')
192 d xmlMmDisplayLast...
193 d pr extproc('xmlMemDisplayLast')
195 d nbBytes value like(xmlClong)
197 d xmlMemShow pr extproc('xmlMemShow')
199 d nr value like(xmlCint)
201 d xmlMemoryDump pr extproc('xmlMemoryDump')
203 d xmlMemMalloc pr * extproc('xmlMemMalloc') void *
204 d size value like(xmlCsize_t)
206 d xmlMemRealloc pr * extproc('xmlMemRealloc') void *
208 d size value like(xmlCsize_t)
210 d xmlMemFree pr extproc('xmlMemFree')
214 d pr * extproc('xmlMemoryStrdup') char *
215 d str * value options(*string) const char *
217 d xmlMallocLoc pr * extproc('xmlMallocLoc') void *
218 d size value like(xmlCsize_t)
219 d file * value options(*string) const char *
220 d line value like(xmlCint)
222 d xmlReallocLoc pr * extproc('xmlReallocLoc') void *
224 d size value like(xmlCsize_t)
225 d file * value options(*string) const char *
226 d line value like(xmlCint)
228 d xmlMallocAtomicLoc...
229 d pr * extproc('xmlMallocAtomicLoc') void *
230 d size value like(xmlCsize_t)
231 d file * value options(*string) const char *
232 d line value like(xmlCint)
235 d pr * extproc('xmlMemStrdupLoc') char *
236 d str * value options(*string) const char *
237 d file * value options(*string) const char *
238 d line value like(xmlCint)
240 /if not defined(XML_GLOBALS_H)
241 /if not defined(XML_THREADS_H__)
242 /include "libxmlrpg/threads"
243 /include "libxmlrpg/globals"
247 /endif DEBUG_MEMORY_ALLOC__