Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 298

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Crystal Space 1.2.1: csBlockAllocator&lt; T, Allocator, ObjectDispose &gt; Class Template Reference (Crystal Space 1.2.1 Public API Reference)</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="head">
 <tr height="59">
  <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td>
  <td class="head"><h2>Public API Reference</h2></td>
 </tr>
 <tr height="11">
  <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td>
 </tr>
</table>
<div class="content">
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.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="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</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>
<h1>csBlockAllocator&lt; T, Allocator, ObjectDispose &gt; Class Template Reference<br>
<small>
[<a class="el" href="group__util__memory.html">Memory Management</a>]</small>
</h1><!-- doxytag: class="csBlockAllocator" --><!-- doxytag: inherits="csFixedSizeAllocator&lt; sizeof(T), Allocator &gt;" -->This class implements a memory allocator which can efficiently allocate objects that all have the same size.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="blockallocator_8h-source.html">csutil/blockallocator.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for csBlockAllocator&lt; T, Allocator, ObjectDispose &gt;:</div>
<div class="dynsection">
<p><center><img src="classcsBlockAllocator__inherit__graph.png" border="0" usemap="#csBlockAllocator_3_01T_00_01Allocator_00_01ObjectDispose_01_4__inherit__map" alt="Inheritance graph"></center>
<map name="csBlockAllocator_3_01T_00_01Allocator_00_01ObjectDispose_01_4__inherit__map">
<area shape="rect" href="classcsFixedSizeAllocator.html" title="csFixedSizeAllocator\&lt; sizeof(T), Allocator \&gt;" alt="" coords="17,7,316,33"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>

<p>
<a href="classcsBlockAllocator-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="1d9fba4c4fe8f5f6504c0953b879026d"></a><!-- doxytag: member="csBlockAllocator::AllocatorType" ref="1d9fba4c4fe8f5f6504c0953b879026d" args="" -->
typedef Allocator&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#1d9fba4c4fe8f5f6504c0953b879026d">AllocatorType</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4710c6bd2ffbf296353a3fd9953cc221"></a><!-- doxytag: member="csBlockAllocator::ThisType" ref="4710c6bd2ffbf296353a3fd9953cc221" args="" -->
typedef <br>
<a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T,<br>
 Allocator &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#4710c6bd2ffbf296353a3fd9953cc221">ThisType</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="35eed981347bb115e554e8dc6142aa11"></a><!-- doxytag: member="csBlockAllocator::ValueType" ref="35eed981347bb115e554e8dc6142aa11" args="" -->
typedef T&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#35eed981347bb115e554e8dc6142aa11">ValueType</a></td></tr>

<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">T *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#2fda57e30eb28fd3cec4ac33322e0daa">Alloc</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate a new object.  <a href="#2fda57e30eb28fd3cec4ac33322e0daa"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#d8f422778b7c2fa33ee76c77f409b0c3">csBlockAllocator</a> (size_t nelem=32)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct a new block allocator.  <a href="#d8f422778b7c2fa33ee76c77f409b0c3"></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="classcsBlockAllocator.html#799b3de443ebd5b4fc807c08dc64404d">Empty</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy all objects allocated by the pool.  <a href="#799b3de443ebd5b4fc807c08dc64404d"></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="classcsBlockAllocator.html#4d331c017f7173bc4f6922dd72eb1535">Free</a> (T *p)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Deallocate an object.  <a href="#4d331c017f7173bc4f6922dd72eb1535"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#06bc80b173329739a612e43ef6257e53">TryFree</a> (T *p)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Try to delete an object.  <a href="#06bc80b173329739a612e43ef6257e53"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#6d21fa52f4c7bb6c4ebf469b8882aee8">~csBlockAllocator</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy all allocated objects and release memory.  <a href="#6d21fa52f4c7bb6c4ebf469b8882aee8"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Protected Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="5f246f5d86f2b83531ed5b7e09562618"></a><!-- doxytag: member="csBlockAllocator::superclass" ref="5f246f5d86f2b83531ed5b7e09562618" args="" -->
typedef <br>
<a class="el" href="classcsFixedSizeAllocator.html">csFixedSizeAllocator</a><br>
&lt; sizeof(T),<br>
 Allocator &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsBlockAllocator.html#5f246f5d86f2b83531ed5b7e09562618">superclass</a></td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt;<br>
 class csBlockAllocator&lt; T, Allocator, ObjectDispose &gt;</h3>

This class implements a memory allocator which can efficiently allocate objects that all have the same size. 
<p>
It has no memory overhead per allocation (unless the objects are smaller than sizeof(void*) bytes) and is extremely fast, both for <a class="el" href="classcsBlockAllocator.html#2fda57e30eb28fd3cec4ac33322e0daa" title="Allocate a new object.">Alloc()</a> and <a class="el" href="classcsBlockAllocator.html#4d331c017f7173bc4f6922dd72eb1535" title="Deallocate an object.">Free()</a>. The only restriction is that any specific allocator can be used for just one type of object (the type for which the template is instantiated). <dl class="remark" compact><dt><b>Remarks:</b></dt><dd>The objects are properly constructed and destructed.<p>
Assumes that the class <code>T</code> with which the template is instantiated has a default (zero-argument) constructor. <a class="el" href="classcsBlockAllocator.html#2fda57e30eb28fd3cec4ac33322e0daa" title="Allocate a new object.">Alloc()</a> uses this constructor to initialize each vended object.<p>
Defining the macro CS_BLOCKALLOC_DEBUG will cause freed objects to be overwritten with '0xfb' bytes. This can be useful to track use of already freed objects, as they can be more easily recognized (as some members will be likely bogus.) </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classcsArray.html" title="A templated array class.">csArray</a> <p>
<a class="el" href="classcsMemoryPool.html" title="A quick-allocation pool for storage of arbitrary data.">csMemoryPool</a> </dd></dl>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00130">130</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="d8f422778b7c2fa33ee76c77f409b0c3"></a><!-- doxytag: member="csBlockAllocator::csBlockAllocator" ref="d8f422778b7c2fa33ee76c77f409b0c3" args="(size_t nelem=32)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::<a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>           </td>
          <td>(</td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>nelem</em> = <code>32</code>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Construct a new block allocator. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>nelem</em>&nbsp;</td><td>Number of elements to store in each allocation unit. </td></tr>
  </table>
</dl>
<dl class="remark" compact><dt><b>Remarks:</b></dt><dd>Bigger values for <code>nelem</code> will improve allocation performance, but at the cost of having some potential waste if you do not add <code>nelem</code> elements to each pool. For instance, if <code>nelem</code> is 50 but you only add 3 elements to the pool, then the space for the remaining 47 elements, though allocated, will remain unused (until you add more elements).<p>
If use use <a class="el" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">csBlockAllocator</a> as a convenient and lightweight garbage collection facility (for which it is well-suited), and expect it to dispose of allocated objects when the pool itself is destroyed, then set <code>warn_unfreed</code> to false. On the other hand, if you use <a class="el" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">csBlockAllocator</a> only as a fast allocator but intend to manage each object's life time manually, then you may want to set <code>warn_unfreed</code> to true in order to receive diagnostics about objects which you have forgotten to release explicitly via manual invocation of <a class="el" href="classcsBlockAllocator.html#4d331c017f7173bc4f6922dd72eb1535" title="Deallocate an object.">Free()</a>. </dd></dl>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00163">163</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="6d21fa52f4c7bb6c4ebf469b8882aee8"></a><!-- doxytag: member="csBlockAllocator::~csBlockAllocator" ref="6d21fa52f4c7bb6c4ebf469b8882aee8" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::~<a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Destroy all allocated objects and release memory. 
<p>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00170">170</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="2fda57e30eb28fd3cec4ac33322e0daa"></a><!-- doxytag: member="csBlockAllocator::Alloc" ref="2fda57e30eb28fd3cec4ac33322e0daa" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* <a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::Alloc           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Allocate a new object. 
<p>
The default (no-argument) constructor of <em>T</em> is invoked. 
<p>Reimplemented from <a class="el" href="classcsFixedSizeAllocator.html#a23579349fa21fff8f1fa6dc30f5f427">csFixedSizeAllocator&lt; sizeof(T), Allocator &gt;</a>.</p>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00191">191</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="799b3de443ebd5b4fc807c08dc64404d"></a><!-- doxytag: member="csBlockAllocator::Empty" ref="799b3de443ebd5b4fc807c08dc64404d" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::Empty           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Destroy all objects allocated by the pool. 
<p>
<dl class="remark" compact><dt><b>Remarks:</b></dt><dd>All pointers returned by <a class="el" href="classcsBlockAllocator.html#2fda57e30eb28fd3cec4ac33322e0daa" title="Allocate a new object.">Alloc()</a> are invalidated. It is safe to perform new allocations from the pool after invoking <a class="el" href="classcsBlockAllocator.html#799b3de443ebd5b4fc807c08dc64404d" title="Destroy all objects allocated by the pool.">Empty()</a>. </dd></dl>

<p>Reimplemented from <a class="el" href="classcsFixedSizeAllocator.html#8684d2f1d4b9c68d779f8b213fc89a2b">csFixedSizeAllocator&lt; sizeof(T), Allocator &gt;</a>.</p>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00181">181</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

<p>Referenced by <a class="el" href="redblacktree_8h-source.html#l00506">csRedBlackTree&lt; csRedBlackTreePayload&lt; K, T &gt; &gt;::DeleteAll()</a>.</p>

</div>
</div><p>
<a class="anchor" name="4d331c017f7173bc4f6922dd72eb1535"></a><!-- doxytag: member="csBlockAllocator::Free" ref="4d331c017f7173bc4f6922dd72eb1535" args="(T *p)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::Free           </td>
          <td>(</td>
          <td class="paramtype">T *&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Deallocate an object. 
<p>
It is safe to provide a null pointer. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>p</em>&nbsp;</td><td>Pointer to deallocate. </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00200">200</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

<p>Referenced by <a class="el" href="redblacktree_8h-source.html#l00214">csRedBlackTree&lt; csRedBlackTreePayload&lt; K, T &gt; &gt;::DeleteNode()</a>.</p>

</div>
</div><p>
<a class="anchor" name="06bc80b173329739a612e43ef6257e53"></a><!-- doxytag: member="csBlockAllocator::TryFree" ref="06bc80b173329739a612e43ef6257e53" args="(T *p)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, class Allocator = CS::Memory::AllocatorMalloc, class ObjectDispose = csBlockAllocatorDisposeDelete&lt;T&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classcsBlockAllocator.html">csBlockAllocator</a>&lt; T, Allocator, ObjectDispose &gt;::TryFree           </td>
          <td>(</td>
          <td class="paramtype">T *&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Try to delete an object. 
<p>
Usage is the same as <a class="el" href="classcsBlockAllocator.html#4d331c017f7173bc4f6922dd72eb1535" title="Deallocate an object.">Free()</a>, the difference being that <code>false</code> is returned if the deallocation failed (the reason is most likely that the memory was not allocated by the allocator). 
<p>Definition at line <a class="el" href="blockallocator_8h-source.html#l00210">210</a> of file <a class="el" href="blockallocator_8h-source.html">blockallocator.h</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>csutil/<a class="el" href="blockallocator_8h-source.html">blockallocator.h</a></ul>
<hr size="1"><address><small>Generated for Crystal Space 1.2.1 by 
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 
</small></address> </div></body> </html>