xref: /aosp_15_r20/external/libxml2/doc/devhelp/libxml2-xmlmemory.html (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>xmlmemory: interface for the memory allocator</title>
5<meta name="generator" content="Libxml2 devhelp stylesheet">
6<link rel="start" href="index.html" title="libxml2 Reference Manual">
7<link rel="up" href="general.html" title="API">
8<link rel="stylesheet" href="style.css" type="text/css">
9<link rel="chapter" href="general.html" title="API">
10</head>
11<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
12<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
13<td><a accesskey="p" href="libxml2-xmlexports.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
14<td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
15<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
16<td><a accesskey="n" href="libxml2-xmlmodule.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
17<th width="100%" align="center">libxml2 Reference Manual</th>
18</tr></table>
19<h2><span class="refentrytitle">xmlmemory</span></h2>
20<p>xmlmemory - interface for the memory allocator</p>
21<p>provides interfaces for the memory allocator, including debugging capabilities. </p>
22<p>Author(s): Daniel Veillard </p>
23<div class="refsynopsisdiv">
24<h2>Synopsis</h2>
25<pre class="synopsis">void	<a href="#xmlCleanupMemory">xmlCleanupMemory</a>		(void);
26typedef void <a href="#xmlFreeFunc">xmlFreeFunc</a>			(void * mem);
27int	<a href="#xmlGcMemGet">xmlGcMemGet</a>			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocAtomicFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc);
28int	<a href="#xmlGcMemSetup">xmlGcMemSetup</a>			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocAtomicFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc);
29int	<a href="#xmlInitMemory">xmlInitMemory</a>			(void);
30void *	<a href="#xmlMallocAtomicLoc">xmlMallocAtomicLoc</a>		(size_t size, <br>					 const char * file, <br>					 int line);
31typedef void * <a href="#xmlMallocFunc">xmlMallocFunc</a>			(size_t size);
32void *	<a href="#xmlMallocLoc">xmlMallocLoc</a>			(size_t size, <br>					 const char * file, <br>					 int line);
33int	<a href="#xmlMemBlocks">xmlMemBlocks</a>			(void);
34void	<a href="#xmlMemDisplay">xmlMemDisplay</a>			(FILE * fp);
35void	<a href="#xmlMemDisplayLast">xmlMemDisplayLast</a>		(FILE * fp, <br>					 long nbBytes);
36void	<a href="#xmlMemFree">xmlMemFree</a>			(void * ptr);
37int	<a href="#xmlMemGet">xmlMemGet</a>			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc);
38void *	<a href="#xmlMemMalloc">xmlMemMalloc</a>			(size_t size);
39void *	<a href="#xmlMemRealloc">xmlMemRealloc</a>			(void * ptr, <br>					 size_t size);
40int	<a href="#xmlMemSetup">xmlMemSetup</a>			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc);
41void	<a href="#xmlMemShow">xmlMemShow</a>			(FILE * fp, <br>					 int nr);
42size_t	<a href="#xmlMemSize">xmlMemSize</a>			(void * ptr);
43char *	<a href="#xmlMemStrdupLoc">xmlMemStrdupLoc</a>			(const char * str, <br>					 const char * file, <br>					 int line);
44int	<a href="#xmlMemUsed">xmlMemUsed</a>			(void);
45void	<a href="#xmlMemoryDump">xmlMemoryDump</a>			(void);
46char *	<a href="#xmlMemoryStrdup">xmlMemoryStrdup</a>			(const char * str);
47typedef void * <a href="#xmlReallocFunc">xmlReallocFunc</a>			(void * mem, <br>					 size_t size);
48void *	<a href="#xmlReallocLoc">xmlReallocLoc</a>			(void * ptr, <br>					 size_t size, <br>					 const char * file, <br>					 int line);
49typedef char * <a href="#xmlStrdupFunc">xmlStrdupFunc</a>			(const char * str);
50</pre>
51</div>
52<div class="refsect1" lang="en"><h2>Description</h2></div>
53<div class="refsect1" lang="en">
54<h2>Details</h2>
55<div class="refsect2" lang="en">
56<div class="refsect2" lang="en">
57<h3>
58<a name="xmlFreeFunc"></a>Function type xmlFreeFunc</h3>
59<pre class="programlisting">void	xmlFreeFunc			(void * mem)<br>
60</pre>
61<p>Signature for a free() implementation.</p>
62<div class="variablelist"><table border="0">
63<col align="left">
64<tbody><tr>
65<td><span class="term"><i><tt>mem</tt></i>:</span></td>
66<td>an already allocated block of memory</td>
67</tr></tbody>
68</table></div>
69</div>
70<hr>
71<div class="refsect2" lang="en">
72<h3>
73<a name="xmlMallocFunc"></a>Function type xmlMallocFunc</h3>
74<pre class="programlisting">void *	xmlMallocFunc			(size_t size)<br>
75</pre>
76<p>Signature for a malloc() implementation.</p>
77<div class="variablelist"><table border="0">
78<col align="left">
79<tbody>
80<tr>
81<td><span class="term"><i><tt>size</tt></i>:</span></td>
82<td>the size requested in bytes</td>
83</tr>
84<tr>
85<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
86<td>a pointer to the newly allocated block or NULL in case of error.</td>
87</tr>
88</tbody>
89</table></div>
90</div>
91<hr>
92<div class="refsect2" lang="en">
93<h3>
94<a name="xmlReallocFunc"></a>Function type xmlReallocFunc</h3>
95<pre class="programlisting">void *	xmlReallocFunc			(void * mem, <br>					 size_t size)<br>
96</pre>
97<p>Signature for a realloc() implementation.</p>
98<div class="variablelist"><table border="0">
99<col align="left">
100<tbody>
101<tr>
102<td><span class="term"><i><tt>mem</tt></i>:</span></td>
103<td>an already allocated block of memory</td>
104</tr>
105<tr>
106<td><span class="term"><i><tt>size</tt></i>:</span></td>
107<td>the new size requested in bytes</td>
108</tr>
109<tr>
110<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
111<td>a pointer to the newly reallocated block or NULL in case of error.</td>
112</tr>
113</tbody>
114</table></div>
115</div>
116<hr>
117<div class="refsect2" lang="en">
118<h3>
119<a name="xmlStrdupFunc"></a>Function type xmlStrdupFunc</h3>
120<pre class="programlisting">char *	xmlStrdupFunc			(const char * str)<br>
121</pre>
122<p>Signature for an strdup() implementation.</p>
123<div class="variablelist"><table border="0">
124<col align="left">
125<tbody>
126<tr>
127<td><span class="term"><i><tt>str</tt></i>:</span></td>
128<td>a zero terminated string</td>
129</tr>
130<tr>
131<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
132<td>the copy of the string or NULL in case of error.</td>
133</tr>
134</tbody>
135</table></div>
136</div>
137<hr>
138<div class="refsect2" lang="en">
139<h3>
140<a name="xmlFree">Variable </a>xmlFree</h3>
141<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> xmlFree;
142</pre>
143<p>@mem: an already allocated block of memory The variable holding the libxml free() implementation</p>
144</div>
145<hr>
146<div class="refsect2" lang="en">
147<h3>
148<a name="xmlMalloc">Variable </a>xmlMalloc</h3>
149<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMalloc;
150</pre>
151<p>@size: the size requested in bytes The variable holding the libxml malloc() implementation Returns a pointer to the newly allocated block or NULL in case of error</p>
152</div>
153<hr>
154<div class="refsect2" lang="en">
155<h3>
156<a name="xmlMallocAtomic">Variable </a>xmlMallocAtomic</h3>
157<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> xmlMallocAtomic;
158</pre>
159<p>@size: the size requested in bytes The variable holding the libxml malloc() implementation for atomic data (i.e. blocks not containing pointers), useful when using a garbage collecting allocator. Returns a pointer to the newly allocated block or NULL in case of error</p>
160</div>
161<hr>
162<div class="refsect2" lang="en">
163<h3>
164<a name="xmlMemStrdup">Variable </a>xmlMemStrdup</h3>
165<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> xmlMemStrdup;
166</pre>
167<p>@str: a zero terminated string The variable holding the libxml strdup() implementation Returns the copy of the string or NULL in case of error</p>
168</div>
169<hr>
170<div class="refsect2" lang="en">
171<h3>
172<a name="xmlRealloc">Variable </a>xmlRealloc</h3>
173<pre class="programlisting"><a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> xmlRealloc;
174</pre>
175<p>@mem: an already allocated block of memory @size: the new size requested in bytes The variable holding the libxml realloc() implementation Returns a pointer to the newly reallocated block or NULL in case of error</p>
176</div>
177<hr>
178<div class="refsect2" lang="en">
179<h3>
180<a name="xmlCleanupMemory"></a>xmlCleanupMemory ()</h3>
181<pre class="programlisting">void	xmlCleanupMemory		(void)<br>
182</pre>
183<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
184</div>
185<hr>
186<div class="refsect2" lang="en">
187<h3>
188<a name="xmlGcMemGet"></a>xmlGcMemGet ()</h3>
189<pre class="programlisting">int	xmlGcMemGet			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocAtomicFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br>
190</pre>
191<p>Provides the memory access functions set currently in use The mallocAtomicFunc is specialized for atomic block allocations (i.e. of areas useful for garbage collected memory allocators</p>
192<div class="variablelist"><table border="0">
193<col align="left">
194<tbody>
195<tr>
196<td><span class="term"><i><tt>freeFunc</tt></i>:</span></td>
197<td>place to save the free() function in use</td>
198</tr>
199<tr>
200<td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td>
201<td>place to save the malloc() function in use</td>
202</tr>
203<tr>
204<td><span class="term"><i><tt>mallocAtomicFunc</tt></i>:</span></td>
205<td>place to save the atomic malloc() function in use</td>
206</tr>
207<tr>
208<td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td>
209<td>place to save the realloc() function in use</td>
210</tr>
211<tr>
212<td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td>
213<td>place to save the strdup() function in use</td>
214</tr>
215<tr>
216<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
217<td>0 on success</td>
218</tr>
219</tbody>
220</table></div>
221</div>
222<hr>
223<div class="refsect2" lang="en">
224<h3>
225<a name="xmlGcMemSetup"></a>xmlGcMemSetup ()</h3>
226<pre class="programlisting">int	xmlGcMemSetup			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocAtomicFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br>
227</pre>
228<p>Override the default memory access functions with a new set This has to be called before any other libxml routines ! The mallocAtomicFunc is specialized for atomic block allocations (i.e. of areas useful for garbage collected memory allocators Should this be blocked if there was already some allocations done ?</p>
229<div class="variablelist"><table border="0">
230<col align="left">
231<tbody>
232<tr>
233<td><span class="term"><i><tt>freeFunc</tt></i>:</span></td>
234<td>the free() function to use</td>
235</tr>
236<tr>
237<td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td>
238<td>the malloc() function to use</td>
239</tr>
240<tr>
241<td><span class="term"><i><tt>mallocAtomicFunc</tt></i>:</span></td>
242<td>the malloc() function to use for atomic allocations</td>
243</tr>
244<tr>
245<td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td>
246<td>the realloc() function to use</td>
247</tr>
248<tr>
249<td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td>
250<td>the strdup() function to use</td>
251</tr>
252<tr>
253<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
254<td>0 on success</td>
255</tr>
256</tbody>
257</table></div>
258</div>
259<hr>
260<div class="refsect2" lang="en">
261<h3>
262<a name="xmlInitMemory"></a>xmlInitMemory ()</h3>
263<pre class="programlisting">int	xmlInitMemory			(void)<br>
264</pre>
265<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
266<div class="variablelist"><table border="0">
267<col align="left">
268<tbody><tr>
269<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
270<td>0.</td>
271</tr></tbody>
272</table></div>
273</div>
274<hr>
275<div class="refsect2" lang="en">
276<h3>
277<a name="xmlMallocAtomicLoc"></a>xmlMallocAtomicLoc ()</h3>
278<pre class="programlisting">void *	xmlMallocAtomicLoc		(size_t size, <br>					 const char * file, <br>					 int line)<br>
279</pre>
280<p>DEPRECATED: don't use</p>
281<div class="variablelist"><table border="0">
282<col align="left">
283<tbody>
284<tr>
285<td><span class="term"><i><tt>size</tt></i>:</span></td>
286<td>an unsigned int specifying the size in byte to allocate.</td>
287</tr>
288<tr>
289<td><span class="term"><i><tt>file</tt></i>:</span></td>
290<td>the file name or NULL</td>
291</tr>
292<tr>
293<td><span class="term"><i><tt>line</tt></i>:</span></td>
294<td>the line number</td>
295</tr>
296<tr>
297<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
298<td>a pointer to the allocated area or NULL in case of lack of memory.</td>
299</tr>
300</tbody>
301</table></div>
302</div>
303<hr>
304<div class="refsect2" lang="en">
305<h3>
306<a name="xmlMallocLoc"></a>xmlMallocLoc ()</h3>
307<pre class="programlisting">void *	xmlMallocLoc			(size_t size, <br>					 const char * file, <br>					 int line)<br>
308</pre>
309<p>DEPRECATED: don't use</p>
310<div class="variablelist"><table border="0">
311<col align="left">
312<tbody>
313<tr>
314<td><span class="term"><i><tt>size</tt></i>:</span></td>
315<td>an int specifying the size in byte to allocate.</td>
316</tr>
317<tr>
318<td><span class="term"><i><tt>file</tt></i>:</span></td>
319<td>the file name or NULL</td>
320</tr>
321<tr>
322<td><span class="term"><i><tt>line</tt></i>:</span></td>
323<td>the line number</td>
324</tr>
325<tr>
326<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
327<td>a pointer to the allocated area or NULL in case of lack of memory.</td>
328</tr>
329</tbody>
330</table></div>
331</div>
332<hr>
333<div class="refsect2" lang="en">
334<h3>
335<a name="xmlMemBlocks"></a>xmlMemBlocks ()</h3>
336<pre class="programlisting">int	xmlMemBlocks			(void)<br>
337</pre>
338<p>Provides the number of memory areas currently allocated</p>
339<div class="variablelist"><table border="0">
340<col align="left">
341<tbody><tr>
342<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
343<td>an int representing the number of blocks</td>
344</tr></tbody>
345</table></div>
346</div>
347<hr>
348<div class="refsect2" lang="en">
349<h3>
350<a name="xmlMemDisplay"></a>xmlMemDisplay ()</h3>
351<pre class="programlisting">void	xmlMemDisplay			(FILE * fp)<br>
352</pre>
353<p>DEPRECATED: This feature was removed.</p>
354<div class="variablelist"><table border="0">
355<col align="left">
356<tbody><tr>
357<td><span class="term"><i><tt>fp</tt></i>:</span></td>
358<td>a FILE descriptor</td>
359</tr></tbody>
360</table></div>
361</div>
362<hr>
363<div class="refsect2" lang="en">
364<h3>
365<a name="xmlMemDisplayLast"></a>xmlMemDisplayLast ()</h3>
366<pre class="programlisting">void	xmlMemDisplayLast		(FILE * fp, <br>					 long nbBytes)<br>
367</pre>
368<p>DEPRECATED: This feature was removed.</p>
369<div class="variablelist"><table border="0">
370<col align="left">
371<tbody>
372<tr>
373<td><span class="term"><i><tt>fp</tt></i>:</span></td>
374<td>a FILE descriptor</td>
375</tr>
376<tr>
377<td><span class="term"><i><tt>nbBytes</tt></i>:</span></td>
378<td>the amount of memory to dump</td>
379</tr>
380</tbody>
381</table></div>
382</div>
383<hr>
384<div class="refsect2" lang="en">
385<h3>
386<a name="xmlMemFree"></a>xmlMemFree ()</h3>
387<pre class="programlisting">void	xmlMemFree			(void * ptr)<br>
388</pre>
389<p>a free() equivalent, with error checking.</p>
390<div class="variablelist"><table border="0">
391<col align="left">
392<tbody><tr>
393<td><span class="term"><i><tt>ptr</tt></i>:</span></td>
394<td>the memory block pointer</td>
395</tr></tbody>
396</table></div>
397</div>
398<hr>
399<div class="refsect2" lang="en">
400<h3>
401<a name="xmlMemGet"></a>xmlMemGet ()</h3>
402<pre class="programlisting">int	xmlMemGet			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br>
403</pre>
404<p>Provides the memory access functions set currently in use</p>
405<div class="variablelist"><table border="0">
406<col align="left">
407<tbody>
408<tr>
409<td><span class="term"><i><tt>freeFunc</tt></i>:</span></td>
410<td>place to save the free() function in use</td>
411</tr>
412<tr>
413<td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td>
414<td>place to save the malloc() function in use</td>
415</tr>
416<tr>
417<td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td>
418<td>place to save the realloc() function in use</td>
419</tr>
420<tr>
421<td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td>
422<td>place to save the strdup() function in use</td>
423</tr>
424<tr>
425<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
426<td>0 on success</td>
427</tr>
428</tbody>
429</table></div>
430</div>
431<hr>
432<div class="refsect2" lang="en">
433<h3>
434<a name="xmlMemMalloc"></a>xmlMemMalloc ()</h3>
435<pre class="programlisting">void *	xmlMemMalloc			(size_t size)<br>
436</pre>
437<p>a malloc() equivalent, with logging of the allocation info.</p>
438<div class="variablelist"><table border="0">
439<col align="left">
440<tbody>
441<tr>
442<td><span class="term"><i><tt>size</tt></i>:</span></td>
443<td>an int specifying the size in byte to allocate.</td>
444</tr>
445<tr>
446<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
447<td>a pointer to the allocated area or NULL in case of lack of memory.</td>
448</tr>
449</tbody>
450</table></div>
451</div>
452<hr>
453<div class="refsect2" lang="en">
454<h3>
455<a name="xmlMemRealloc"></a>xmlMemRealloc ()</h3>
456<pre class="programlisting">void *	xmlMemRealloc			(void * ptr, <br>					 size_t size)<br>
457</pre>
458<p>a realloc() equivalent, with logging of the allocation info.</p>
459<div class="variablelist"><table border="0">
460<col align="left">
461<tbody>
462<tr>
463<td><span class="term"><i><tt>ptr</tt></i>:</span></td>
464<td>the initial memory block pointer</td>
465</tr>
466<tr>
467<td><span class="term"><i><tt>size</tt></i>:</span></td>
468<td>an int specifying the size in byte to allocate.</td>
469</tr>
470<tr>
471<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
472<td>a pointer to the allocated area or NULL in case of lack of memory.</td>
473</tr>
474</tbody>
475</table></div>
476</div>
477<hr>
478<div class="refsect2" lang="en">
479<h3>
480<a name="xmlMemSetup"></a>xmlMemSetup ()</h3>
481<pre class="programlisting">int	xmlMemSetup			(<a href="libxml2-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br>					 <a href="libxml2-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br>
482</pre>
483<p>Override the default memory access functions with a new set This has to be called before any other libxml routines ! Should this be blocked if there was already some allocations done ?</p>
484<div class="variablelist"><table border="0">
485<col align="left">
486<tbody>
487<tr>
488<td><span class="term"><i><tt>freeFunc</tt></i>:</span></td>
489<td>the free() function to use</td>
490</tr>
491<tr>
492<td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td>
493<td>the malloc() function to use</td>
494</tr>
495<tr>
496<td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td>
497<td>the realloc() function to use</td>
498</tr>
499<tr>
500<td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td>
501<td>the strdup() function to use</td>
502</tr>
503<tr>
504<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
505<td>0 on success</td>
506</tr>
507</tbody>
508</table></div>
509</div>
510<hr>
511<div class="refsect2" lang="en">
512<h3>
513<a name="xmlMemShow"></a>xmlMemShow ()</h3>
514<pre class="programlisting">void	xmlMemShow			(FILE * fp, <br>					 int nr)<br>
515</pre>
516<p>DEPRECATED: This feature was removed.</p>
517<div class="variablelist"><table border="0">
518<col align="left">
519<tbody>
520<tr>
521<td><span class="term"><i><tt>fp</tt></i>:</span></td>
522<td>a FILE descriptor</td>
523</tr>
524<tr>
525<td><span class="term"><i><tt>nr</tt></i>:</span></td>
526<td>number of entries to dump</td>
527</tr>
528</tbody>
529</table></div>
530</div>
531<hr>
532<div class="refsect2" lang="en">
533<h3>
534<a name="xmlMemSize"></a>xmlMemSize ()</h3>
535<pre class="programlisting">size_t	xmlMemSize			(void * ptr)<br>
536</pre>
537<p></p>
538<div class="variablelist"><table border="0">
539<col align="left">
540<tbody>
541<tr>
542<td><span class="term"><i><tt>ptr</tt></i>:</span></td>
543<td>pointer to the memory allocation</td>
544</tr>
545<tr>
546<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
547<td>the size of a memory allocation.</td>
548</tr>
549</tbody>
550</table></div>
551</div>
552<hr>
553<div class="refsect2" lang="en">
554<h3>
555<a name="xmlMemStrdupLoc"></a>xmlMemStrdupLoc ()</h3>
556<pre class="programlisting">char *	xmlMemStrdupLoc			(const char * str, <br>					 const char * file, <br>					 int line)<br>
557</pre>
558<p>DEPRECATED: don't use</p>
559<div class="variablelist"><table border="0">
560<col align="left">
561<tbody>
562<tr>
563<td><span class="term"><i><tt>str</tt></i>:</span></td>
564<td>the initial string pointer</td>
565</tr>
566<tr>
567<td><span class="term"><i><tt>file</tt></i>:</span></td>
568<td>the file name or NULL</td>
569</tr>
570<tr>
571<td><span class="term"><i><tt>line</tt></i>:</span></td>
572<td>the line number</td>
573</tr>
574<tr>
575<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
576<td>a pointer to the new string or NULL if allocation error occurred.</td>
577</tr>
578</tbody>
579</table></div>
580</div>
581<hr>
582<div class="refsect2" lang="en">
583<h3>
584<a name="xmlMemUsed"></a>xmlMemUsed ()</h3>
585<pre class="programlisting">int	xmlMemUsed			(void)<br>
586</pre>
587<p>Provides the amount of memory currently allocated</p>
588<div class="variablelist"><table border="0">
589<col align="left">
590<tbody><tr>
591<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
592<td>an int representing the amount of memory allocated.</td>
593</tr></tbody>
594</table></div>
595</div>
596<hr>
597<div class="refsect2" lang="en">
598<h3>
599<a name="xmlMemoryDump"></a>xmlMemoryDump ()</h3>
600<pre class="programlisting">void	xmlMemoryDump			(void)<br>
601</pre>
602<p>DEPRECATED: This feature was removed.</p>
603</div>
604<hr>
605<div class="refsect2" lang="en">
606<h3>
607<a name="xmlMemoryStrdup"></a>xmlMemoryStrdup ()</h3>
608<pre class="programlisting">char *	xmlMemoryStrdup			(const char * str)<br>
609</pre>
610<p>a strdup() equivalent, with logging of the allocation info.</p>
611<div class="variablelist"><table border="0">
612<col align="left">
613<tbody>
614<tr>
615<td><span class="term"><i><tt>str</tt></i>:</span></td>
616<td>the initial string pointer</td>
617</tr>
618<tr>
619<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
620<td>a pointer to the new string or NULL if allocation error occurred.</td>
621</tr>
622</tbody>
623</table></div>
624</div>
625<hr>
626<div class="refsect2" lang="en">
627<h3>
628<a name="xmlReallocLoc"></a>xmlReallocLoc ()</h3>
629<pre class="programlisting">void *	xmlReallocLoc			(void * ptr, <br>					 size_t size, <br>					 const char * file, <br>					 int line)<br>
630</pre>
631<p>DEPRECATED: don't use</p>
632<div class="variablelist"><table border="0">
633<col align="left">
634<tbody>
635<tr>
636<td><span class="term"><i><tt>ptr</tt></i>:</span></td>
637<td>the initial memory block pointer</td>
638</tr>
639<tr>
640<td><span class="term"><i><tt>size</tt></i>:</span></td>
641<td>an int specifying the size in byte to allocate.</td>
642</tr>
643<tr>
644<td><span class="term"><i><tt>file</tt></i>:</span></td>
645<td>the file name or NULL</td>
646</tr>
647<tr>
648<td><span class="term"><i><tt>line</tt></i>:</span></td>
649<td>the line number</td>
650</tr>
651<tr>
652<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
653<td>a pointer to the allocated area or NULL in case of lack of memory.</td>
654</tr>
655</tbody>
656</table></div>
657</div>
658<hr>
659</div>
660</div>
661</body>
662</html>
663