tidy-html5/htmldoc/api/group__Memory.html

266 lines
14 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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>HTML Tidy: Memory Allocation</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<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">4.9.15</span>
</div>
<div id="projectbrief">The HTACG Tidy HTML Project</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){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><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><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 class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><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 class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga3fe8c5ac7d658618c732565776940ed8"><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 class="separator:ga3fe8c5ac7d658618c732565776940ed8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga78e96524a88db0c09e766795265863da"><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 class="separator:ga78e96524a88db0c09e766795265863da"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga787c17cc35380584873e99e37c181640"><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#ga787c17cc35380584873e99e37c181640">TidyMalloc</a>) (size_t len)</td></tr>
<tr class="separator:ga787c17cc35380584873e99e37c181640"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8d63ea537373a328acf80feb89ccfef1"><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#ga8d63ea537373a328acf80feb89ccfef1">TidyRealloc</a>) (void *buf, size_t len)</td></tr>
<tr class="separator:ga8d63ea537373a328acf80feb89ccfef1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaada345a86e699dfaadd8fe06718b98c1"><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#gaada345a86e699dfaadd8fe06718b98c1">TidyFree</a>) (void *buf)</td></tr>
<tr class="separator:gaada345a86e699dfaadd8fe06718b98c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad5fef9c3b423d924226b2a99f99c7d51"><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#gad5fef9c3b423d924226b2a99f99c7d51">TidyPanic</a>) (ctmbstr mssg)</td></tr>
<tr class="separator:gad5fef9c3b423d924226b2a99f99c7d51"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gab55079374527525e3374ebc4d2a1e625"><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#ga787c17cc35380584873e99e37c181640">TidyMalloc</a> fmalloc)</td></tr>
<tr class="separator:gab55079374527525e3374ebc4d2a1e625"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga446b538da3ee3f2e5a3827b877665b30"><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#ga8d63ea537373a328acf80feb89ccfef1">TidyRealloc</a> frealloc)</td></tr>
<tr class="separator:ga446b538da3ee3f2e5a3827b877665b30"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga70e707b7df86effb5727b0b9ff64eed7"><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#gaada345a86e699dfaadd8fe06718b98c1">TidyFree</a> ffree)</td></tr>
<tr class="separator:ga70e707b7df86effb5727b0b9ff64eed7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab12cc0435bacec1a8c725e02357acc00"><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#gad5fef9c3b423d924226b2a99f99c7d51">TidyPanic</a> fpanic)</td></tr>
<tr class="separator:gab12cc0435bacec1a8c725e02357acc00"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">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>
<h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="ga3fe8c5ac7d658618c732565776940ed8"></a>
<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>
<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="ga787c17cc35380584873e99e37c181640"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void*(TIDY_CALL * TidyMalloc) (size_t len)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Callback for "malloc" replacement </p>
</div>
</div>
<a class="anchor" id="ga8d63ea537373a328acf80feb89ccfef1"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void*(TIDY_CALL * TidyRealloc) (void *buf, size_t len)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Callback for "realloc" replacement </p>
</div>
</div>
<a class="anchor" id="gaada345a86e699dfaadd8fe06718b98c1"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void(TIDY_CALL * TidyFree) (void *buf)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Callback for "free" replacement </p>
</div>
</div>
<a class="anchor" id="gad5fef9c3b423d924226b2a99f99c7d51"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void(TIDY_CALL * TidyPanic) (ctmbstr mssg)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Callback for "out of memory" panic state </p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gab55079374527525e3374ebc4d2a1e625"></a>
<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#ga787c17cc35380584873e99e37c181640">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>
<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#ga8d63ea537373a328acf80feb89ccfef1">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>
<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#gaada345a86e699dfaadd8fe06718b98c1">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>
<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#gad5fef9c3b423d924226b2a99f99c7d51">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><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Fri Feb 13 2015 12:51:21 for HTML Tidy by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
</ul>
</div>
</body>
</html>