165eacac05a89076c51e52568aeeab6154fc2f0b
[platform/upstream/libxml2.git] / os400 / libxmlrpg / xmlmemory.rpgle
1       * Summary: interface for the memory allocator
2       * Description: provides interfaces for the memory allocator,
3       *              including debugging capabilities.
4       *
5       * Copy: See Copyright for the status of this software.
6       *
7       * Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
8
9       /if not defined(DEBUG_MEMORY_ALLOC__)
10       /define DEBUG_MEMORY_ALLOC__
11
12       /include "libxmlrpg/xmlversion"
13
14       * DEBUG_MEMORY:
15       *
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.
20
21       * /define DEBUG_MEMORY_FREED
22       * /define DEBUG_MEMORY_LOCATION
23
24       /if defined(DEBUG)
25       /if not defined(DEBUG_MEMORY)
26       /define DEBUG_MEMORY
27       /endif
28       /endif
29
30       * DEBUG_MEMORY_LOCATION:
31       *
32       * DEBUG_MEMORY_LOCATION should be activated only when debugging
33       * libxml i.e. if libxml has been configured with --with-debug-mem too.
34
35       /if defined(DEBUG_MEMORY_LOCATION)
36       /endif
37
38       * The XML memory wrapper support 4 basic overloadable functions.
39
40       * xmlFreeFunc:
41       * @mem: an already allocated block of memory
42       *
43       * Signature for a free() implementation.
44
45      d xmlFreeFunc     s               *   based(######typedef######)
46      d                                     procptr
47
48       * xmlMallocFunc:
49       * @size:  the size requested in bytes
50       *
51       * Signature for a malloc() implementation.
52       *
53       * Returns a pointer to the newly allocated block or NULL in case of error.
54
55      d xmlMallocFunc   s               *   based(######typedef######)
56      d                                     procptr
57
58       * xmlReallocFunc:
59       * @mem: an already allocated block of memory
60       * @size:  the new size requested in bytes
61       *
62       * Signature for a realloc() implementation.
63       *
64       * Returns a pointer to the newly reallocated block or NULL in case of error.
65
66      d xmlReallocFunc  s               *   based(######typedef######)
67      d                                     procptr
68
69       * xmlStrdupFunc:
70       * @str: a zero terminated string
71       *
72       * Signature for an strdup() implementation.
73       *
74       * Returns the copy of the string or NULL in case of error.
75
76      d xmlStrdupFunc   s               *   based(######typedef######)
77      d                                     procptr
78
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.
82
83      d get_xmlFree     pr                  extproc('__get_xmlFree')
84      d                                     like(xmlFreeFunc)
85
86      d set_xmlFree     pr                  extproc('__set_xmlFree')
87      d  func                               value like(xmlFreeFunc)
88
89      d xmlFree         pr                  extproc('__call_xmlFree')
90      d  mem                            *   value                                void *
91
92      d get_xmlMalloc   pr                  extproc('__get_xmlMalloc')
93      d                                     like(xmlMallocFunc)
94
95      d set_xmlMalloc   pr                  extproc('__set_xmlMalloc')
96      d  func                               value like(xmlMallocFunc)
97
98      d xmlMalloc       pr              *   extproc('__call_xmlMalloc')          void *
99      d  size                         10u 0 value                                size_t
100
101      d get_xmlMallocAtomic...
102      d                 pr                  extproc('__get_xmlMallocAtomic')
103      d                                     like(xmlMallocFunc)
104
105      d set_xmlMallocAtomic...
106      d                 pr                  extproc('__set_xmlMallocAtomic')
107      d  func                               value like(xmlMallocFunc)
108
109      d xmlMallocAtomic...
110      d                 pr              *   extproc('__call_xmlMallocAtomic')    void *
111      d  size                         10u 0 value                                size_t
112
113      d get_xmlRealloc  pr                  extproc('__get_xmlRealloc')
114      d                                     like(xmlReallocFunc)
115
116      d set_xmlRealloc  pr                  extproc('__set_xmlRealloc')
117      d  func                               value like(xmlReallocFunc)
118
119      d xmlRealloc      pr              *   extproc('__call_xmlRealloc')         void *
120      d  mem                            *   value                                void *
121      d  size                         10u 0 value                                size_t
122
123      d get_xmlMemStrdup...
124      d                 pr                  extproc('__get_xmlMemStrdup')
125      d                                     like(xmlStrdupFunc)
126
127      d set_xmlMemStrdup...
128      d                 pr                  extproc('__set_xmlMemstrdup')
129      d  func                               value like(xmlStrdupFunc)
130
131      d xmlMemStrdup    pr              *   extproc('__call_xmlMemStrdup')          void *
132      d  str                            *   value options(*string)               const char *
133
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
137
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)
143
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)
149
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)
157
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)
165
166       * Initialization of the memory layer.
167
168      d xmlInitMemory   pr            10i 0 extproc('xmlInitMemory')
169
170       * Cleanup of the memory layer.
171
172      d xmlCleanupMemory...
173      d                 pr                  extproc('xmlCleanupMemory')
174
175       * These are specific to the XML debug memory wrapper.
176
177      d xmlMemUsed      pr            10i 0 extproc('xmlMemUsed')
178
179      d xmlMemBlocks    pr            10i 0 extproc('xmlMemBlocks')
180
181      d xmlMemDisplay   pr                  extproc('xmlMemDisplay')
182      d  fp                             *   value                                FILE *
183
184      d xmlMmDisplayLast...
185      d                 pr                  extproc('xmlMemDisplayLast')
186      d  fp                             *   value                                FILE *
187      d  nbBytes                      20i 0 value
188
189      d xmlMemShow      pr                  extproc('xmlMemShow')
190      d  fp                             *   value                                FILE *
191      d  nr                           10i 0 value
192
193      d xmlMemoryDump   pr                  extproc('xmlMemoryDump')
194
195      d xmlMemMalloc    pr              *   extproc('xmlMemMalloc')              void *
196      d  size                         10u 0 value                                size_t
197
198      d xmlMemRealloc   pr              *   extproc('xmlMemRealloc')             void *
199      d  ptr                            *   value                                void *
200      d  size                         10u 0 value                                size_t
201
202      d xmlMemFree      pr                  extproc('xmlMemFree')
203      d  ptr                            *   value                                void *
204
205      d xmlMemoryStrdup...
206      d                 pr              *   extproc('xmlMemoryStrdup')           char *
207      d  str                            *   value options(*string)               const char *
208
209      d xmlMallocLoc    pr              *   extproc('xmlMallocLoc')              void *
210      d  size                         10u 0 value                                size_t
211      d  file                           *   value options(*string)               const char *
212      d  line                         10i 0 value
213
214      d xmlReallocLoc   pr              *   extproc('xmlReallocLoc')              void *
215      d  ptr                            *   value                                void *
216      d  size                         10u 0 value                                size_t
217      d  file                           *   value options(*string)               const char *
218      d  line                         10i 0 value
219
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 *
224      d  line                         10i 0 value
225
226      d xmlMemStrdupLoc...
227      d                 pr              *   extproc('xmlMemStrdupLoc')           char *
228      d  str                            *   value options(*string)               const char *
229      d  file                           *   value options(*string)               const char *
230      d  line                         10i 0 value
231
232       /if not defined(XML_GLOBALS_H)
233       /if not defined(XML_THREADS_H__)
234       /include "libxmlrpg/threads"
235       /include "libxmlrpg/globals"
236       /endif
237       /endif
238
239       /endif                                                                    DEBUG_MEMORY_ALLOC__