Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > by-pkgid > 092973e3430682b17a7d74261285ae23 > files > 70

loki-lib-doc-0.1.7-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Loki::FixedAllocator Class 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.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;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 class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</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="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00192.html">Loki</a>::<a class="el" href="a00056.html">FixedAllocator</a>
  </div>
</div>
<div class="contents">
<h1>Loki::FixedAllocator Class Reference<br>
<small>
[<a class="el" href="a00217.html">Internals</a>]</small>
</h1><!-- doxytag: class="Loki::FixedAllocator" --><div class="dynheader">
Collaboration diagram for Loki::FixedAllocator:</div>
<div class="dynsection">
<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center></div>

<p>
<a href="a00450.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="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#ce7ad725a2f44c427641f4ce629a3aac">FixedAllocator</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a <a class="el" href="a00056.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="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#080589e92d310aeb4e432d195bcd7ba5">~FixedAllocator</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy the <a class="el" href="a00056.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&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#5fb8edbf26f6ab26a0c332391909fa0c">Initialize</a> (std::size_t blockSize, std::size_t pageSize)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initializes a <a class="el" href="a00056.html">FixedAllocator</a> by calculating # of blocks per <a class="el" href="a00025.html">Chunk</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#c29973a11534fb1006fd28db97a17bed">Allocate</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#49ab7ca3364fe05f2d7d91248ee5d0e3">Deallocate</a> (void *p, <a class="el" href="a00025.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&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#37df732230913b2dd9126a6b311586f0">BlockSize</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns block size with which the <a class="el" href="a00056.html">FixedAllocator</a> was initialized. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#4df95a9324de31f05d931f2eea25165e">TrimEmptyChunk</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#2b92d73c032c2ae6942ef9aadf6f27fc">TrimChunkList</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">std::size_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#e74cbab50e78bfa115d7c0fcdce00641">CountEmptyChunks</a> (void) const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#41a7ad189cba00f504635aade8b3d15c">IsCorrupt</a> (void) const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00025.html">Chunk</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.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="a00025.html">Chunk</a> which owns some blocks.<p>
<dl class="user" compact><dt><b>Class Level Invariants</b></dt><dd><ul>
<li>There is always either zero or one <a class="el" href="a00025.html">Chunk</a> which is empty.</li><li>If this has no empty <a class="el" href="a00025.html">Chunk</a>, then emptyChunk_ is NULL.</li><li>If this has an empty <a class="el" href="a00025.html">Chunk</a>, then emptyChunk_ points to it.</li><li>If the <a class="el" href="a00025.html">Chunk</a> container is empty, then deallocChunk_ and allocChunk_ are NULL.</li><li>If the <a class="el" href="a00025.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="a00025.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>
<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&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns pointer to allocated memory block of fixed size - or NULL if it failed to allocate. 
<p>References <a class="el" href="a00261.html#l00358">Loki::Chunk::Allocate()</a>, <a class="el" href="a00261.html#l00586">CountEmptyChunks()</a>, <a class="el" href="a00261.html#l00138">Loki::Chunk::HasAvailable()</a>, <a class="el" href="a00261.html#l00401">Loki::Chunk::IsCorrupt()</a>, and <a class="el" href="a00261.html#l00141">Loki::Chunk::IsFilled()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l01109">Loki::SmallObjAllocator::Allocate()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</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&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td> 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. 
<p>References <a class="el" href="a00261.html#l00138">Loki::Chunk::HasAvailable()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l00831">Allocate()</a>, <a class="el" href="a00261.html#l00888">Deallocate()</a>, <a class="el" href="a00261.html#l00607">IsCorrupt()</a>, and <a class="el" href="a00261.html#l00736">TrimEmptyChunk()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</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 *&nbsp;</td>
          <td class="paramname"> <em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00025.html">Chunk</a> *&nbsp;</td>
          <td class="paramname"> <em>hint</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></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="a00056.html">FixedAllocator</a>, it returns false so that <a class="el" href="a00127.html">SmallObjAllocator</a> can call the default deallocator. If the block was found, this returns true. 
<p>References <a class="el" href="a00261.html#l00586">CountEmptyChunks()</a>, <a class="el" href="a00261.html#l00132">Loki::Chunk::HasBlock()</a>, <a class="el" href="a00261.html#l00502">Loki::Chunk::IsBlockAvailable()</a>, and <a class="el" href="a00261.html#l00401">Loki::Chunk::IsCorrupt()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l01144">Loki::SmallObjAllocator::Deallocate()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</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="a00025.html">Chunk</a> * Loki::FixedAllocator::HasBlock           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns true if the block at address p is within a <a class="el" href="a00025.html">Chunk</a> owned by this <a class="el" href="a00056.html">FixedAllocator</a>. Complexity is O(C) where C is the total number of Chunks - empty or used. 
<p>References <a class="el" href="a00261.html#l00132">Loki::Chunk::HasBlock()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l01168">Loki::SmallObjAllocator::Deallocate()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</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&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Determines if <a class="el" href="a00056.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="a00025.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. 
<p>References <a class="el" href="a00261.html#l00586">CountEmptyChunks()</a>, <a class="el" href="a00261.html#l00138">Loki::Chunk::HasAvailable()</a>, and <a class="el" href="a00261.html#l00401">Loki::Chunk::IsCorrupt()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</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&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></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 class="return" 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&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Releases the memory used by the empty <a class="el" href="a00025.html">Chunk</a>. This will take constant time under any situation. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if empty chunk found and released, false if none empty. </dd></dl>

<p>References <a class="el" href="a00261.html#l00149">Loki::Chunk::blocksAvailable_</a>, <a class="el" href="a00261.html#l00586">CountEmptyChunks()</a>, <a class="el" href="a00261.html#l00138">Loki::Chunk::HasAvailable()</a>, and <a class="el" href="a00261.html#l00346">Loki::Chunk::Release()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l00558">~FixedAllocator()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>SmallObj.cpp</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:46 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>