libxml-xmlmemory.html revision 2925c0a0f4ccd9390f73cea230cb96f39c3fbc9f
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><link rel="SHORTCUT ICON" href="/favicon.ico" /><style type="text/css">
4TD {font-family: Verdana,Arial,Helvetica}
5BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
6H1 {font-family: Verdana,Arial,Helvetica}
7H2 {font-family: Verdana,Arial,Helvetica}
8H3 {font-family: Verdana,Arial,Helvetica}
9A:link, A:visited, A:active { text-decoration: underline }
10</style><title>Module xmlmemory from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="/epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="/gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="/w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="/redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="/Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module xmlmemory from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Main Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a href="index.html">Home</a></li><li><a href="examples/index.html" style="font-weight:bold">Code Examples</a></li><li><a href="guidelines.html">XML Guidelines</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><h2>Table of Contents</h2><pre class="programlisting">void *	<a href="#xmlMemRealloc">xmlMemRealloc</a>	(void * ptr, <br />				 size_t size)<br />
11</pre><pre class="programlisting">void *	<a href="#xmlReallocLoc">xmlReallocLoc</a>	(void * ptr, <br />				 size_t size, <br />				 const char * file, <br />				 int line)<br />
12</pre><pre class="programlisting">int	<a href="#xmlGcMemGet">xmlGcMemGet</a>	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocAtomicFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br />
13</pre><pre class="programlisting"><a name="xmlStrdupFunc" id="xmlStrdupFunc"></a>Function type: xmlStrdupFunc
14char *	xmlStrdupFunc	(const char * str)
15</pre><p>Signature for an strdup() implementation.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>a zero terminated string</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the copy of the string or NULL in case of error.</td></tr></tbody></table></div><br />
16<pre class="programlisting"><a name="xmlFreeFunc" id="xmlFreeFunc"></a>Function type: xmlFreeFunc
17void	xmlFreeFunc	(void * mem)
18</pre><p>Signature for a free() implementation.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>mem</tt></i>:</span></td><td>an already allocated block of memory</td></tr></tbody></table></div><br />
19<pre class="programlisting">int	<a href="#xmlInitMemory">xmlInitMemory</a>	(void)<br />
20</pre><pre class="programlisting">Variable <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> <a name="xmlMemStrdup" id="xmlMemStrdup"></a>xmlMemStrdup
21
22</pre><pre class="programlisting">Variable <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> <a name="xmlRealloc" id="xmlRealloc"></a>xmlRealloc
23
24</pre><pre class="programlisting">void	<a href="#xmlMemFree">xmlMemFree</a>	(void * ptr)<br />
25</pre><pre class="programlisting">int	<a href="#xmlMemGet">xmlMemGet</a>	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br />
26</pre><pre class="programlisting">void *	<a href="#xmlMallocAtomicLoc">xmlMallocAtomicLoc</a>	(size_t size, <br />				 const char * file, <br />				 int line)<br />
27</pre><pre class="programlisting">void *	<a href="#xmlMemMalloc">xmlMemMalloc</a>	(size_t size)<br />
28</pre><pre class="programlisting">void	<a href="#xmlMemDisplay">xmlMemDisplay</a>	(FILE * fp)<br />
29</pre><pre class="programlisting">int	<a href="#xmlMemUsed">xmlMemUsed</a>	(void)<br />
30</pre><pre class="programlisting">int	<a href="#xmlMemSetup">xmlMemSetup</a>	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br />
31</pre><pre class="programlisting">Variable <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> <a name="xmlMallocAtomic" id="xmlMallocAtomic"></a>xmlMallocAtomic
32
33</pre><pre class="programlisting">void	<a href="#xmlMemoryDump">xmlMemoryDump</a>	(void)<br />
34</pre><pre class="programlisting">void *	<a href="#xmlMallocLoc">xmlMallocLoc</a>	(size_t size, <br />				 const char * file, <br />				 int line)<br />
35</pre><pre class="programlisting">void	<a href="#xmlMemShow">xmlMemShow</a>	(FILE * fp, <br />				 int nr)<br />
36</pre><pre class="programlisting"><a name="xmlReallocFunc" id="xmlReallocFunc"></a>Function type: xmlReallocFunc
37void *	xmlReallocFunc	(void * mem, <br />				 size_t size)
38</pre><p>Signature for a realloc() implementation.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>mem</tt></i>:</span></td><td>an already allocated block of memory</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the new size requested in bytes</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the newly reallocated block or NULL in case of error.</td></tr></tbody></table></div><br />
39<pre class="programlisting">Variable <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> <a name="xmlMalloc" id="xmlMalloc"></a>xmlMalloc
40
41</pre><pre class="programlisting"><a name="xmlMallocFunc" id="xmlMallocFunc"></a>Function type: xmlMallocFunc
42void *	xmlMallocFunc	(size_t size)
43</pre><p>Signature for a malloc() implementation.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size requested in bytes</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the newly allocated block or NULL in case of error.</td></tr></tbody></table></div><br />
44<pre class="programlisting">#define <a href="#DEBUG_MEMORY">DEBUG_MEMORY</a>
45
46</pre><pre class="programlisting">int	<a href="#xmlGcMemSetup">xmlGcMemSetup</a>	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocAtomicFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br />
47</pre><pre class="programlisting">char *	<a href="#xmlMemoryStrdup">xmlMemoryStrdup</a>	(const char * str)<br />
48</pre><pre class="programlisting">char *	<a href="#xmlMemStrdupLoc">xmlMemStrdupLoc</a>	(const char * str, <br />				 const char * file, <br />				 int line)<br />
49</pre><h2>Description</h2>
50<h3><a name="xmlMemRealloc" id="xmlMemRealloc"></a>Function: xmlMemRealloc</h3><pre class="programlisting">void *	xmlMemRealloc	(void * ptr, <br />				 size_t size)<br />
51</pre><p>a realloc() equivalent, with logging of the allocation info.</p>
52<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ptr</tt></i>:</span></td><td>the initial memory block pointer</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlReallocLoc" id="xmlReallocLoc"></a>Function: xmlReallocLoc</h3><pre class="programlisting">void *	xmlReallocLoc	(void * ptr, <br />				 size_t size, <br />				 const char * file, <br />				 int line)<br />
53</pre><p>a realloc() equivalent, with logging of the allocation info.</p>
54<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ptr</tt></i>:</span></td><td>the initial memory block pointer</td></tr><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlGcMemGet" id="xmlGcMemGet"></a>Function: xmlGcMemGet</h3><pre class="programlisting">int	xmlGcMemGet	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocAtomicFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br />
55</pre><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>
56<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>freeFunc</tt></i>:</span></td><td>place to save the free() function in use</td></tr><tr><td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td><td>place to save the malloc() function in use</td></tr><tr><td><span class="term"><i><tt>mallocAtomicFunc</tt></i>:</span></td><td>place to save the atomic malloc() function in use</td></tr><tr><td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td><td>place to save the realloc() function in use</td></tr><tr><td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td><td>place to save the strdup() function in use</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success</td></tr></tbody></table></div>
57      Signature for an strdup() implementation.
58      
59      
60    
61      Signature for a free() implementation.
62      
63      
64    <h3><a name="xmlInitMemory" id="xmlInitMemory"></a>Function: xmlInitMemory</h3><pre class="programlisting">int	xmlInitMemory	(void)<br />
65</pre><p>Initialize the memory layer.</p>
66<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success</td></tr></tbody></table></div><h3><a name="xmlMemFree" id="xmlMemFree"></a>Function: xmlMemFree</h3><pre class="programlisting">void	xmlMemFree	(void * ptr)<br />
67</pre><p>a free() equivalent, with error checking.</p>
68<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ptr</tt></i>:</span></td><td>the memory block pointer</td></tr></tbody></table></div><h3><a name="xmlMemGet" id="xmlMemGet"></a>Function: xmlMemGet</h3><pre class="programlisting">int	xmlMemGet	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)<br />
69</pre><p>Provides the memory access functions set currently in use</p>
70<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>freeFunc</tt></i>:</span></td><td>place to save the free() function in use</td></tr><tr><td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td><td>place to save the malloc() function in use</td></tr><tr><td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td><td>place to save the realloc() function in use</td></tr><tr><td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td><td>place to save the strdup() function in use</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success</td></tr></tbody></table></div><h3><a name="xmlMallocAtomicLoc" id="xmlMallocAtomicLoc"></a>Function: xmlMallocAtomicLoc</h3><pre class="programlisting">void *	xmlMallocAtomicLoc	(size_t size, <br />				 const char * file, <br />				 int line)<br />
71</pre><p>a malloc() equivalent, with logging of the allocation info.</p>
72<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlMemMalloc" id="xmlMemMalloc"></a>Function: xmlMemMalloc</h3><pre class="programlisting">void *	xmlMemMalloc	(size_t size)<br />
73</pre><p>a malloc() equivalent, with logging of the allocation info.</p>
74<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlMemDisplay" id="xmlMemDisplay"></a>Function: xmlMemDisplay</h3><pre class="programlisting">void	xmlMemDisplay	(FILE * fp)<br />
75</pre><p>show in-extenso the memory blocks allocated</p>
76<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>fp</tt></i>:</span></td><td>a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylist</td></tr></tbody></table></div><h3><a name="xmlMemUsed" id="xmlMemUsed"></a>Function: xmlMemUsed</h3><pre class="programlisting">int	xmlMemUsed	(void)<br />
77</pre><p>Provides the amount of memory currently allocated</p>
78<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>an int representing the amount of memory allocated.</td></tr></tbody></table></div><h3><a name="xmlMemSetup" id="xmlMemSetup"></a>Function: xmlMemSetup</h3><pre class="programlisting">int	xmlMemSetup	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br />
79</pre><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>
80<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>freeFunc</tt></i>:</span></td><td>the free() function to use</td></tr><tr><td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td><td>the malloc() function to use</td></tr><tr><td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td><td>the realloc() function to use</td></tr><tr><td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td><td>the strdup() function to use</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success</td></tr></tbody></table></div><h3><a name="xmlMemoryDump" id="xmlMemoryDump"></a>Function: xmlMemoryDump</h3><pre class="programlisting">void	xmlMemoryDump	(void)<br />
81</pre><p>Dump in-extenso the memory blocks allocated to the file .memorylist</p>
82<h3><a name="xmlMallocLoc" id="xmlMallocLoc"></a>Function: xmlMallocLoc</h3><pre class="programlisting">void *	xmlMallocLoc	(size_t size, <br />				 const char * file, <br />				 int line)<br />
83</pre><p>a malloc() equivalent, with logging of the allocation info.</p>
84<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlMemShow" id="xmlMemShow"></a>Function: xmlMemShow</h3><pre class="programlisting">void	xmlMemShow	(FILE * fp, <br />				 int nr)<br />
85</pre><p>show a show display of the memory allocated, and dump the @nr last allocated areas which were not freed</p>
86<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>fp</tt></i>:</span></td><td>a FILE descriptor used as the output file</td></tr><tr><td><span class="term"><i><tt>nr</tt></i>:</span></td><td>number of entries to dump</td></tr></tbody></table></div>
87      Signature for a realloc() implementation.
88      
89      
90      
91    
92      Signature for a malloc() implementation.
93      
94      
95    <h3><a name="DEBUG_MEMORY" id="DEBUG_MEMORY"></a>Macro: DEBUG_MEMORY</h3><pre>#define DEBUG_MEMORY</pre><p><a href="libxml-xmlmemory.html#DEBUG_MEMORY">DEBUG_MEMORY</a> replaces the allocator with a collect and debug shell to the libc allocator. <a href="libxml-xmlmemory.html#DEBUG_MEMORY">DEBUG_MEMORY</a> should only be activated when debugging libxml i.e. if libxml has been configured with --with-debug-mem too. #define DEBUG_MEMORY_FREED #define <a href="libxml-xmlversion.html#DEBUG_MEMORY_LOCATION">DEBUG_MEMORY_LOCATION</a></p>
96<h3><a name="xmlGcMemSetup" id="xmlGcMemSetup"></a>Function: xmlGcMemSetup</h3><pre class="programlisting">int	xmlGcMemSetup	(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> freeFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> mallocAtomicFunc, <br />				 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> reallocFunc, <br />				 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> strdupFunc)<br />
97</pre><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>
98<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>freeFunc</tt></i>:</span></td><td>the free() function to use</td></tr><tr><td><span class="term"><i><tt>mallocFunc</tt></i>:</span></td><td>the malloc() function to use</td></tr><tr><td><span class="term"><i><tt>mallocAtomicFunc</tt></i>:</span></td><td>the malloc() function to use for atomic allocations</td></tr><tr><td><span class="term"><i><tt>reallocFunc</tt></i>:</span></td><td>the realloc() function to use</td></tr><tr><td><span class="term"><i><tt>strdupFunc</tt></i>:</span></td><td>the strdup() function to use</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 on success</td></tr></tbody></table></div><h3><a name="xmlMemoryStrdup" id="xmlMemoryStrdup"></a>Function: xmlMemoryStrdup</h3><pre class="programlisting">char *	xmlMemoryStrdup	(const char * str)<br />
99</pre><p>a strdup() equivalent, with logging of the allocation info.</p>
100<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the initial string pointer</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the new string or NULL if allocation error occurred.</td></tr></tbody></table></div><h3><a name="xmlMemStrdupLoc" id="xmlMemStrdupLoc"></a>Function: xmlMemStrdupLoc</h3><pre class="programlisting">char *	xmlMemStrdupLoc	(const char * str, <br />				 const char * file, <br />				 int line)<br />
101</pre><p>a strdup() equivalent, with logging of the allocation info.</p>
102<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>str</tt></i>:</span></td><td>the initial string pointer</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the new string or NULL if allocation error occurred.</td></tr></tbody></table></div><p><a href="bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
103