Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 0b492435a0d81f9ba124dcde3e3b696a > files > 42

libtidy-devel-0.99.0-20.20091203.fc13.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>HTML Tidy: Memory Allocation</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="contents">
<h1>Memory Allocation</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct__TidyAllocatorVtbl.html">_TidyAllocatorVtbl</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct__TidyAllocator.html">_TidyAllocator</a></td></tr>
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct__TidyAllocatorVtbl.html">_TidyAllocatorVtbl</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga3fe8c5ac7d658618c732565776940ed8">TidyAllocatorVtbl</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct__TidyAllocator.html">_TidyAllocator</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga78e96524a88db0c09e766795265863da">TidyAllocator</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void *(TIDY_CALL *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga3bd3cc4d0c837a4cd10ab472ba671430">TidyMalloc</a> )(size_t len)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void *(TIDY_CALL *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga9d9a5625817932dbbb39dd33de678edd">TidyRealloc</a> )(void *buf, size_t len)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void(TIDY_CALL *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga27931c443e424937ba47f0d4795aa35f">TidyFree</a> )(void *buf)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void(TIDY_CALL *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga0770be41d9935a3e2933ba0be3c7725c">TidyPanic</a> )(ctmbstr mssg)</td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Bool TIDY_CALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#gab55079374527525e3374ebc4d2a1e625">tidySetMallocCall</a> (<a class="el" href="group__Memory.html#ga3bd3cc4d0c837a4cd10ab472ba671430">TidyMalloc</a> fmalloc)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Bool TIDY_CALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga446b538da3ee3f2e5a3827b877665b30">tidySetReallocCall</a> (<a class="el" href="group__Memory.html#ga9d9a5625817932dbbb39dd33de678edd">TidyRealloc</a> frealloc)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Bool TIDY_CALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#ga70e707b7df86effb5727b0b9ff64eed7">tidySetFreeCall</a> (<a class="el" href="group__Memory.html#ga27931c443e424937ba47f0d4795aa35f">TidyFree</a> ffree)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Bool TIDY_CALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Memory.html#gab12cc0435bacec1a8c725e02357acc00">tidySetPanicCall</a> (<a class="el" href="group__Memory.html#ga0770be41d9935a3e2933ba0be3c7725c">TidyPanic</a> fpanic)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>Tidy uses a user provided allocator for all memory allocations. If this allocator is not provided, then a default allocator is used which simply wraps standard C malloc/free calls. These wrappers call the panic function upon any failure. The default panic function prints an out of memory message to stderr, and calls exit(2).</p>
<p>For applications in which it is unacceptable to abort in the case of memory allocation, then the panic function can be replaced with one which longjmps() out of the tidy code. For this to clean up completely, you should be careful not to use any tidy methods that open files as these will not be closed before panic() is called.</p>
<p>TODO: associate file handles with tidyDoc and ensure that tidyDocRelease() can close them all.</p>
<p>Calling the withAllocator() family ( tidyCreateWithAllocator, tidyBufInitWithAllocator, tidyBufAllocWithAllocator) allow settings custom allocators).</p>
<p>All parts of the document use the same allocator. Calls that require a user provided buffer can optionally use a different allocator.</p>
<p>For reference in designing a plug-in allocator, most allocations made by tidy are less than 100 bytes, corresponding to attribute names/values, etc.</p>
<p>There is also an additional class of much larger allocations which are where most of the data from the lexer is stored. (It is not currently possible to use a separate allocator for the lexer, this would be a useful extension).</p>
<p>In general, approximately 1/3rd of the memory used by tidy is freed during the parse, so if memory usage is an issue then an allocator that can reuse this memory is a good idea. </p>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ga3fe8c5ac7d658618c732565776940ed8"></a><!-- doxytag: member="tidy.h::TidyAllocatorVtbl" ref="ga3fe8c5ac7d658618c732565776940ed8" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="struct__TidyAllocatorVtbl.html">_TidyAllocatorVtbl</a> <a class="el" href="struct__TidyAllocatorVtbl.html">TidyAllocatorVtbl</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The allocators function table </p>

</div>
</div>
<a class="anchor" id="ga78e96524a88db0c09e766795265863da"></a><!-- doxytag: member="tidy.h::TidyAllocator" ref="ga78e96524a88db0c09e766795265863da" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="struct__TidyAllocator.html">_TidyAllocator</a> <a class="el" href="struct__TidyAllocator.html">TidyAllocator</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The allocator </p>

</div>
</div>
<a class="anchor" id="ga3bd3cc4d0c837a4cd10ab472ba671430"></a><!-- doxytag: member="tidy.h::TidyMalloc" ref="ga3bd3cc4d0c837a4cd10ab472ba671430" args=")(size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void*(TIDY_CALL * <a class="el" href="group__Memory.html#ga3bd3cc4d0c837a4cd10ab472ba671430">TidyMalloc</a>)(size_t len)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Callback for "malloc" replacement </p>

</div>
</div>
<a class="anchor" id="ga9d9a5625817932dbbb39dd33de678edd"></a><!-- doxytag: member="tidy.h::TidyRealloc" ref="ga9d9a5625817932dbbb39dd33de678edd" args=")(void *buf, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void*(TIDY_CALL * <a class="el" href="group__Memory.html#ga9d9a5625817932dbbb39dd33de678edd">TidyRealloc</a>)(void *buf, size_t len)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Callback for "realloc" replacement </p>

</div>
</div>
<a class="anchor" id="ga27931c443e424937ba47f0d4795aa35f"></a><!-- doxytag: member="tidy.h::TidyFree" ref="ga27931c443e424937ba47f0d4795aa35f" args=")(void *buf)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(TIDY_CALL * <a class="el" href="group__Memory.html#ga27931c443e424937ba47f0d4795aa35f">TidyFree</a>)(void *buf)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Callback for "free" replacement </p>

</div>
</div>
<a class="anchor" id="ga0770be41d9935a3e2933ba0be3c7725c"></a><!-- doxytag: member="tidy.h::TidyPanic" ref="ga0770be41d9935a3e2933ba0be3c7725c" args=")(ctmbstr mssg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(TIDY_CALL * <a class="el" href="group__Memory.html#ga0770be41d9935a3e2933ba0be3c7725c">TidyPanic</a>)(ctmbstr mssg)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Callback for "out of memory" panic state </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gab55079374527525e3374ebc4d2a1e625"></a><!-- doxytag: member="tidy.h::tidySetMallocCall" ref="gab55079374527525e3374ebc4d2a1e625" args="(TidyMalloc fmalloc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Bool TIDY_CALL tidySetMallocCall </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__Memory.html#ga3bd3cc4d0c837a4cd10ab472ba671430">TidyMalloc</a>&nbsp;</td>
          <td class="paramname"> <em>fmalloc</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Give Tidy a malloc() replacement </p>

</div>
</div>
<a class="anchor" id="ga446b538da3ee3f2e5a3827b877665b30"></a><!-- doxytag: member="tidy.h::tidySetReallocCall" ref="ga446b538da3ee3f2e5a3827b877665b30" args="(TidyRealloc frealloc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Bool TIDY_CALL tidySetReallocCall </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__Memory.html#ga9d9a5625817932dbbb39dd33de678edd">TidyRealloc</a>&nbsp;</td>
          <td class="paramname"> <em>frealloc</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Give Tidy a realloc() replacement </p>

</div>
</div>
<a class="anchor" id="ga70e707b7df86effb5727b0b9ff64eed7"></a><!-- doxytag: member="tidy.h::tidySetFreeCall" ref="ga70e707b7df86effb5727b0b9ff64eed7" args="(TidyFree ffree)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Bool TIDY_CALL tidySetFreeCall </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__Memory.html#ga27931c443e424937ba47f0d4795aa35f">TidyFree</a>&nbsp;</td>
          <td class="paramname"> <em>ffree</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Give Tidy a free() replacement </p>

</div>
</div>
<a class="anchor" id="gab12cc0435bacec1a8c725e02357acc00"></a><!-- doxytag: member="tidy.h::tidySetPanicCall" ref="gab12cc0435bacec1a8c725e02357acc00" args="(TidyPanic fpanic)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Bool TIDY_CALL tidySetPanicCall </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__Memory.html#ga0770be41d9935a3e2933ba0be3c7725c">TidyPanic</a>&nbsp;</td>
          <td class="paramname"> <em>fpanic</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Give Tidy an "out of memory" handler </p>

</div>
</div>
</div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 3 Dec 2009 for HTML Tidy by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>