tidy-html5/htmldoc/api/group__Memory.html
2012-03-01 17:54:20 +09:00

270 lines
13 KiB
HTML

<!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" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">HTML Tidy
&#160;<span id="projectnumber">0.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('group__Memory.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Memory Allocation</div> </div>
</div>
<div class="contents">
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</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 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct__TidyAllocator.html">_TidyAllocator</a></td></tr>
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct__TidyAllocatorVtbl.html">_TidyAllocatorVtbl</a>&#160;</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>&#160;</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 *&#160;</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 *&#160;</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 *&#160;</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 *&#160;</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><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Bool TIDY_CALL&#160;</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&#160;</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&#160;</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&#160;</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" id="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="group__Memory.html#ga3fe8c5ac7d658618c732565776940ed8">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="group__Memory.html#ga78e96524a88db0c09e766795265863da">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>&#160;</td>
<td class="paramname"><em>fmalloc</em></td><td>)</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>&#160;</td>
<td class="paramname"><em>frealloc</em></td><td>)</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>&#160;</td>
<td class="paramname"><em>ffree</em></td><td>)</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>&#160;</td>
<td class="paramname"><em>fpanic</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Give Tidy an "out of memory" handler </p>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="footer">Generated on Thu Mar 1 2012 17:53:35 for HTML Tidy by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
</ul>
</div>
</body>
</html>