tidy-html5/htmldoc/api/struct__TidyAllocator.html

101 lines
4 KiB
HTML
Raw Normal View History

2012-03-01 08:54:20 +00:00
<!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: _TidyAllocator Struct Reference</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('struct__TidyAllocator.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#pub-attribs">Data Fields</a> </div>
<div class="headertitle">
<div class="title">_TidyAllocator Struct Reference<div class="ingroups"><a class="el" href="group__Memory.html">Memory Allocation</a></div></div> </div>
</div>
<div class="contents">
<!-- doxytag: class="_TidyAllocator" -->
<p><code>#include &lt;<a class="el" href="tidy_8h_source.html">tidy.h</a>&gt;</code></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Data Fields</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2113f1c06a3cfe4cbdf9212a47e6938b"></a><!-- doxytag: member="_TidyAllocator::vtbl" ref="a2113f1c06a3cfe4cbdf9212a47e6938b" args="" -->
const <a class="el" href="group__Memory.html#ga3fe8c5ac7d658618c732565776940ed8">TidyAllocatorVtbl</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>vtbl</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>An allocator. To create your own allocator, do something like the following:</p>
<p>typedef struct _MyAllocator { TidyAllocator base; ...other custom allocator state... } MyAllocator;</p>
<p>void* MyAllocator_alloc(TidyAllocator *base, void *block, size_t nBytes) { MyAllocator *self = (MyAllocator*)base; ... } (etc)</p>
<p>static const TidyAllocatorVtbl MyAllocatorVtbl = { MyAllocator_alloc, MyAllocator_realloc, MyAllocator_free, MyAllocator_panic };</p>
<p>myAllocator allocator; <a class="el" href="structTidyDoc.html">TidyDoc</a> doc;</p>
<p>allocator.base.vtbl = &amp;MyAllocatorVtbl; ...initialise allocator specific state... doc = tidyCreateWithAllocator(&amp;allocator); ...</p>
<p>Although this looks slightly long winded, the advantage is that to create a custom allocator you simply need to set the vtbl pointer correctly. The vtbl itself can reside in static/global data, and hence does not need to be initialised each time an allocator is created, and furthermore the memory is shared amongst all created allocators. </p>
</div><hr/>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="tidy_8h_source.html">tidy.h</a></li>
</ul>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="struct__TidyAllocator.html">_TidyAllocator</a> </li>
<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>