1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Loki: Loki::FixedAllocator Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li id="current"><a href="classes.html"><span>Classes</span></a></li>
<li>
<form action="search.php" method="get">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><label> <u>S</u>earch for </label></td>
<td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
</tr>
</table>
</form>
</li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="classes.html"><span>Alphabetical List</span></a></li>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul></div>
<div class="nav">
<a class="el" href="a00764.html">Loki</a>::<a class="el" href="a00674.html">FixedAllocator</a></div>
<h1>Loki::FixedAllocator Class Reference<br>
<small>
[<a class="el" href="a00780.html">Internals</a>]</small>
</h1><!-- doxytag: class="Loki::FixedAllocator" -->Collaboration diagram for Loki::FixedAllocator:<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><a href="a00582.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ce7ad725a2f44c427641f4ce629a3aac"></a><!-- doxytag: member="Loki::FixedAllocator::FixedAllocator" ref="ce7ad725a2f44c427641f4ce629a3aac" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#ce7ad725a2f44c427641f4ce629a3aac">FixedAllocator</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a <a class="el" href="a00674.html">FixedAllocator</a> which manages blocks of 'blockSize' size. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="080589e92d310aeb4e432d195bcd7ba5"></a><!-- doxytag: member="Loki::FixedAllocator::~FixedAllocator" ref="080589e92d310aeb4e432d195bcd7ba5" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#080589e92d310aeb4e432d195bcd7ba5">~FixedAllocator</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy the <a class="el" href="a00674.html">FixedAllocator</a> and release all its Chunks. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="5fb8edbf26f6ab26a0c332391909fa0c"></a><!-- doxytag: member="Loki::FixedAllocator::Initialize" ref="5fb8edbf26f6ab26a0c332391909fa0c" args="(std::size_t blockSize, std::size_t pageSize)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#5fb8edbf26f6ab26a0c332391909fa0c">Initialize</a> (std::size_t blockSize, std::size_t pageSize)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initializes a <a class="el" href="a00674.html">FixedAllocator</a> by calculating # of blocks per <a class="el" href="a00645.html">Chunk</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#c29973a11534fb1006fd28db97a17bed">Allocate</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#49ab7ca3364fe05f2d7d91248ee5d0e3">Deallocate</a> (void *p, <a class="el" href="a00645.html">Chunk</a> *hint)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="37df732230913b2dd9126a6b311586f0"></a><!-- doxytag: member="Loki::FixedAllocator::BlockSize" ref="37df732230913b2dd9126a6b311586f0" args="() const " -->
std::size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#37df732230913b2dd9126a6b311586f0">BlockSize</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns block size with which the <a class="el" href="a00674.html">FixedAllocator</a> was initialized. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#4df95a9324de31f05d931f2eea25165e">TrimEmptyChunk</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#2b92d73c032c2ae6942ef9aadf6f27fc">TrimChunkList</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#e74cbab50e78bfa115d7c0fcdce00641">CountEmptyChunks</a> (void) const </td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#41a7ad189cba00f504635aade8b3d15c">IsCorrupt</a> (void) const </td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00645.html">Chunk</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00674.html#f84b504579cea189ce1c415ee8ed5d2c">HasBlock</a> (void *p) const </td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Offers services for allocating fixed-sized objects. It has a container of "containers" of fixed-size blocks. The outer container has all the Chunks. The inner container is a <a class="el" href="a00645.html">Chunk</a> which owns some blocks.<p>
<dl compact><dt><b>Class Level Invariants</b></dt><dd><ul>
<li>There is always either zero or one <a class="el" href="a00645.html">Chunk</a> which is empty.</li><li>If this has no empty <a class="el" href="a00645.html">Chunk</a>, then emptyChunk_ is NULL.</li><li>If this has an empty <a class="el" href="a00645.html">Chunk</a>, then emptyChunk_ points to it.</li><li>If the <a class="el" href="a00645.html">Chunk</a> container is empty, then deallocChunk_ and allocChunk_ are NULL.</li><li>If the <a class="el" href="a00645.html">Chunk</a> container is not-empty, then deallocChunk_ and allocChunk_ are either NULL or point to Chunks within the container.</li><li>allocChunk_ will often point to the last <a class="el" href="a00645.html">Chunk</a> in the container since it was likely allocated most recently, and therefore likely to have an available block. </li></ul>
</dd></dl>
<p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="c29973a11534fb1006fd28db97a17bed"></a><!-- doxytag: member="Loki::FixedAllocator::Allocate" ref="c29973a11534fb1006fd28db97a17bed" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * Loki::FixedAllocator::Allocate </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Returns pointer to allocated memory block of fixed size - or NULL if it failed to allocate.
</div>
</div><p>
<a class="anchor" name="e74cbab50e78bfa115d7c0fcdce00641"></a><!-- doxytag: member="Loki::FixedAllocator::CountEmptyChunks" ref="e74cbab50e78bfa115d7c0fcdce00641" args="(void) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::size_t Loki::FixedAllocator::CountEmptyChunks </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Returns count of empty Chunks held by this allocator. Complexity is O(C) where C is the total number of Chunks - empty or used.
</div>
</div><p>
<a class="anchor" name="49ab7ca3364fe05f2d7d91248ee5d0e3"></a><!-- doxytag: member="Loki::FixedAllocator::Deallocate" ref="49ab7ca3364fe05f2d7d91248ee5d0e3" args="(void *p, Chunk *hint)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Loki::FixedAllocator::Deallocate </td>
<td>(</td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="a00645.html">Chunk</a> * </td>
<td class="paramname"> <em>hint</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Deallocate a memory block previously allocated with Allocate. If the block is not owned by this <a class="el" href="a00674.html">FixedAllocator</a>, it returns false so that <a class="el" href="a00714.html">SmallObjAllocator</a> can call the default deallocator. If the block was found, this returns true.
</div>
</div><p>
<a class="anchor" name="f84b504579cea189ce1c415ee8ed5d2c"></a><!-- doxytag: member="Loki::FixedAllocator::HasBlock" ref="f84b504579cea189ce1c415ee8ed5d2c" args="(void *p) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const <a class="el" href="a00645.html">Chunk</a> * Loki::FixedAllocator::HasBlock </td>
<td>(</td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>p</em> </td>
<td> ) </td>
<td width="100%"> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Returns true if the block at address p is within a <a class="el" href="a00645.html">Chunk</a> owned by this <a class="el" href="a00674.html">FixedAllocator</a>. Complexity is O(C) where C is the total number of Chunks - empty or used.
</div>
</div><p>
<a class="anchor" name="41a7ad189cba00f504635aade8b3d15c"></a><!-- doxytag: member="Loki::FixedAllocator::IsCorrupt" ref="41a7ad189cba00f504635aade8b3d15c" args="(void) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Loki::FixedAllocator::IsCorrupt </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Determines if <a class="el" href="a00674.html">FixedAllocator</a> is corrupt. Checks data members to see if any have erroneous values, or violate class invariants. It also checks if any <a class="el" href="a00645.html">Chunk</a> is corrupt. Complexity is O(C) where C is the number of Chunks. If any data is corrupt, this will return true in release mode, or assert in debug mode.
</div>
</div><p>
<a class="anchor" name="2b92d73c032c2ae6942ef9aadf6f27fc"></a><!-- doxytag: member="Loki::FixedAllocator::TrimChunkList" ref="2b92d73c032c2ae6942ef9aadf6f27fc" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Loki::FixedAllocator::TrimChunkList </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Releases unused spots from ChunkList. This takes constant time with respect to # of Chunks, but actual time depends on underlying memory allocator. <dl compact><dt><b>Returns:</b></dt><dd>False if no unused spots, true if some found and released. </dd></dl>
</div>
</div><p>
<a class="anchor" name="4df95a9324de31f05d931f2eea25165e"></a><!-- doxytag: member="Loki::FixedAllocator::TrimEmptyChunk" ref="4df95a9324de31f05d931f2eea25165e" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Loki::FixedAllocator::TrimEmptyChunk </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Releases the memory used by the empty <a class="el" href="a00645.html">Chunk</a>. This will take constant time under any situation. <dl compact><dt><b>Returns:</b></dt><dd>True if empty chunk found and released, false if none empty. </dd></dl>
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>SmallObj.cpp</ul>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 15:14:44 2006 for Loki by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>
|