Sophie

Sophie

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

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: _TidyAllocator Struct Reference</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>_TidyAllocator Struct Reference<br/>
<small>
[<a class="el" href="group__Memory.html">Memory Allocation</a>]</small>
</h1><!-- doxytag: class="_TidyAllocator" -->
<p><code>#include &lt;<a class="el" href="tidy_8h_source.html">tidy.h</a>&gt;</code></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>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="struct__TidyAllocatorVtbl.html">TidyAllocatorVtbl</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><b>vtbl</b></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<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>
<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>
<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>