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"
16 * DEBUG_MEMORY replaces the allocator with a collect and debug
17 * shell to the libc allocator.
18 * DEBUG_MEMORY should only be activated when debugging
19 * libxml i.e. if libxml has been configured with --with-debug-mem too.
21 * /define DEBUG_MEMORY_FREED
22 * /define DEBUG_MEMORY_LOCATION
25 /if not defined(DEBUG_MEMORY)
30 * DEBUG_MEMORY_LOCATION:
32 * DEBUG_MEMORY_LOCATION should be activated only when debugging
33 * libxml i.e. if libxml has been configured with --with-debug-mem too.
35 /if defined(DEBUG_MEMORY_LOCATION)
38 * The XML memory wrapper support 4 basic overloadable functions.
41 * @mem: an already allocated block of memory
43 * Signature for a free() implementation.
45 d xmlFreeFunc s * based(######typedef######)
49 * @size: the size requested in bytes
51 * Signature for a malloc() implementation.
53 * Returns a pointer to the newly allocated block or NULL in case of error.
55 d xmlMallocFunc s * based(######typedef######)
59 * @mem: an already allocated block of memory
60 * @size: the new size requested in bytes
62 * Signature for a realloc() implementation.
64 * Returns a pointer to the newly reallocated block or NULL in case of error.
66 d xmlReallocFunc s * based(######typedef######)
70 * @str: a zero terminated string
72 * Signature for an strdup() implementation.
74 * Returns the copy of the string or NULL in case of error.
76 d xmlStrdupFunc s * based(######typedef######)
79 * The 5 interfaces used for all memory handling within libxml.
80 * Since indirect calls are only supported via a based prototype,
81 * storage is accessed via functions.
83 d get_xmlFree pr extproc('__get_xmlFree')
86 d set_xmlFree pr extproc('__set_xmlFree')
87 d func value like(xmlFreeFunc)
89 d xmlFree pr extproc('__call_xmlFree')
92 d get_xmlMalloc pr extproc('__get_xmlMalloc')
95 d set_xmlMalloc pr extproc('__set_xmlMalloc')
96 d func value like(xmlMallocFunc)
98 d xmlMalloc pr * extproc('__call_xmlMalloc') void *
99 d size 10u 0 value size_t
101 d get_xmlMallocAtomic...
102 d pr extproc('__get_xmlMallocAtomic')
103 d like(xmlMallocFunc)
105 d set_xmlMallocAtomic...
106 d pr extproc('__set_xmlMallocAtomic')
107 d func value like(xmlMallocFunc)
110 d pr * extproc('__call_xmlMallocAtomic') void *
111 d size 10u 0 value size_t
113 d get_xmlRealloc pr extproc('__get_xmlRealloc')
114 d like(xmlReallocFunc)
116 d set_xmlRealloc pr extproc('__set_xmlRealloc')
117 d func value like(xmlReallocFunc)
119 d xmlRealloc pr * extproc('__call_xmlRealloc') void *
121 d size 10u 0 value size_t
123 d get_xmlMemStrdup...
124 d pr extproc('__get_xmlMemStrdup')
125 d like(xmlStrdupFunc)
127 d set_xmlMemStrdup...
128 d pr extproc('__set_xmlMemstrdup')
129 d func value like(xmlStrdupFunc)
131 d xmlMemStrdup pr * extproc('__call_xmlMemStrdup') void *
132 d str * value options(*string) const char *
134 * The way to overload the existing functions.
135 * The xmlGc function have an extra entry for atomic block
136 * allocations useful for garbage collected memory allocators
138 d xmlMemSetup pr 10i 0 extproc('xmlMemSetup')
139 d freeFunc value like(xmlFreeFunc)
140 d mallocFunc value like(xmlMallocFunc)
141 d reallocFunc value like(xmlReallocFunc)
142 d strdupFunc value like(xmlStrdupFunc)
144 d xmlMemGet pr 10i 0 extproc('xmlMemGet')
145 d freeFunc like(xmlFreeFunc)
146 d mallocFunc like(xmlMallocFunc)
147 d reallocFunc like(xmlReallocFunc)
148 d strdupFunc like(xmlStrdupFunc)
150 d xmlGcMemSetup pr 10i 0 extproc('xmlGcMemSetup')
151 d freeFunc value like(xmlFreeFunc)
152 d mallocFunc value like(xmlMallocFunc)
153 d mallocAtomicFunc...
154 d value like(xmlMallocFunc)
155 d reallocFunc value like(xmlReallocFunc)
156 d strdupFunc value like(xmlStrdupFunc)
158 d xmlGcMemGet pr 10i 0 extproc('xmlGcMemGet')
159 d freeFunc like(xmlFreeFunc)
160 d mallocFunc like(xmlMallocFunc)
161 d mallocAtomicFunc...
162 d like(xmlMallocFunc)
163 d reallocFunc like(xmlReallocFunc)
164 d strdupFunc like(xmlStrdupFunc)
166 * Initialization of the memory layer.
168 d xmlInitMemory pr 10i 0 extproc('xmlInitMemory')
170 * Cleanup of the memory layer.
172 d xmlCleanupMemory...
173 d pr extproc('xmlCleanupMemory')
175 * These are specific to the XML debug memory wrapper.
177 d xmlMemUsed pr 10i 0 extproc('xmlMemUsed')
179 d xmlMemBlocks pr 10i 0 extproc('xmlMemBlocks')
181 d xmlMemDisplay pr extproc('xmlMemDisplay')
184 d xmlMmDisplayLast...
185 d pr extproc('xmlMemDisplayLast')
187 d nbBytes 20i 0 value
189 d xmlMemShow pr extproc('xmlMemShow')
193 d xmlMemoryDump pr extproc('xmlMemoryDump')
195 d xmlMemMalloc pr * extproc('xmlMemMalloc') void *
196 d size 10u 0 value size_t
198 d xmlMemRealloc pr * extproc('xmlMemRealloc') void *
200 d size 10u 0 value size_t
202 d xmlMemFree pr extproc('xmlMemFree')
206 d pr * extproc('xmlMemoryStrdup') char *
207 d str * value options(*string) const char *
209 d xmlMallocLoc pr * extproc('xmlMallocLoc') void *
210 d size 10u 0 value size_t
211 d file * value options(*string) const char *
214 d xmlReallocLoc pr * extproc('xmlReallocLoc') void *
216 d size 10u 0 value size_t
217 d file * value options(*string) const char *
220 d xmlMallocAtomicLoc...
221 d pr * extproc('xmlMallocAtomicLoc') void *
222 d size 10u 0 value size_t
223 d file * value options(*string) const char *
227 d pr * extproc('xmlMemStrdupLoc') char *
228 d str * value options(*string) const char *
229 d file * value options(*string) const char *
232 /if not defined(XML_GLOBALS_H)
233 /if not defined(XML_THREADS_H__)
234 /include "libxmlrpg/threads"
235 /include "libxmlrpg/globals"
239 /endif DEBUG_MEMORY_ALLOC__