aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/block__memory_8h-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/block__memory_8h-source.html')
-rw-r--r--docs/doxygen/nel/block__memory_8h-source.html339
1 files changed, 339 insertions, 0 deletions
diff --git a/docs/doxygen/nel/block__memory_8h-source.html b/docs/doxygen/nel/block__memory_8h-source.html
new file mode 100644
index 00000000..649612ec
--- /dev/null
+++ b/docs/doxygen/nel/block__memory_8h-source.html
@@ -0,0 +1,339 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>block_memory.h</h1><a href="block__memory_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#ifndef NL_BLOCK_MEMORY_H</font>
+00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_BLOCK_MEMORY_H</font>
+00028 <font class="preprocessor"></font>
+00029 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
+00030 <font class="preprocessor">#include &lt;list&gt;</font>
+00031 <font class="preprocessor">#include &lt;vector&gt;</font>
+00032 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
+00033
+00034
+00035 <font class="keyword">namespace </font>NLMISC
+00036 {
+00037
+00038
+00039 <font class="comment">// ***************************************************************************</font>
+00041 <font class="comment">extern bool NL3D_BlockMemoryAssertOnPurge; // =true.</font>
+00042
+00043
+00044 <font class="comment">// ***************************************************************************</font>
+00063 <font class="comment"></font><font class="keyword">template</font>&lt;<font class="keyword">class</font> T, <font class="keywordtype">bool</font> __ctor_dtor__= true &gt;
+<a name="l00064"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html">00064</a> <font class="keyword">class </font>CBlockMemory
+00065 {
+00066 <font class="keyword">public</font>:
+00067
+<a name="l00069"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a0">00069</a> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a0">CBlockMemory</a>(uint blockSize= 16)
+00070 {
+00071 <a class="code" href="debug_8h.html#a6">nlassert</a>(blockSize);
+00072 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a>= blockSize;
+00073 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>= std::max(<font class="keyword">sizeof</font>(T), <font class="keyword">sizeof</font>(<font class="keywordtype">void</font>*));
+00074 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= NULL;
+00075 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>= 0;
+00076 }
+00077 <font class="comment">// just copy setup from other blockMemory, don't copy data!</font>
+<a name="l00078"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a1">00078</a> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a0">CBlockMemory</a>(<font class="keyword">const</font> CBlockMemory&lt;T, __ctor_dtor__&gt; &amp;other)
+00079 {
+00080 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a>= other._BlockSize;
+00081 <font class="comment">// if other block is rebinded, don't copy its rebinded size.</font>
+00082 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>= std::max(<font class="keyword">sizeof</font>(T), <font class="keyword">sizeof</font>(<font class="keywordtype">void</font>*));
+00083 <font class="comment">// No elts allocated</font>
+00084 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= NULL;
+00085 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>= 0;
+00086 }
+<a name="l00089"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a2">00089</a> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a2">~CBlockMemory</a>()
+00090 {
+00091 <a class="code" href="classNLMISC_1_1CBlockMemory.html#a5">purge</a>();
+00092 }
+00093
+00094
+<a name="l00096"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a3">00096</a> T* <a class="code" href="classNLMISC_1_1CBlockMemory.html#a3">allocate</a>()
+00097 {
+00098 <font class="comment">// if not enough memory, aloc a block.</font>
+00099 <font class="keywordflow">if</font>(!<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>)
+00100 {
+00101 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.push_front(CBlock());
+00102 <a class="code" href="classNLMISC_1_1CBlockMemory.html#c0">buildBlock</a>(*<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.begin());
+00103 <font class="comment">// new free elt points to the beginning of this block.</font>
+00104 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= (*<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.begin()).Data;
+00105 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00106 <font class="preprocessor"></font> <font class="comment">// if debug, must decal for begin check.</font>
+00107 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= (uint32*)<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a> + 1;
+00108 <font class="preprocessor">#endif</font>
+00109 <font class="preprocessor"></font> }
+00110
+00111 <font class="comment">// choose next free elt.</font>
+00112 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>);
+00113 T* ret= (T*)<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>;
+00114
+00115 <font class="comment">// update _NextFreeElt, so it points to the next free element.</font>
+00116 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= *(<font class="keywordtype">void</font>**)<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>;
+00117
+00118 <font class="comment">// construct the allocated element.</font>
+00119 <font class="keywordflow">if</font>( __ctor_dtor__ )
+00120 <font class="preprocessor">#undef new</font>
+00121 <font class="preprocessor"></font> <font class="keyword">new</font> (ret) T;
+00122 <font class="preprocessor">#define new NL_NEW</font>
+00123 <font class="preprocessor"></font>
+00124
+00125 <font class="comment">// some simple Check.</font>
+00126 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00127 <font class="preprocessor"></font> uint32 *checkStart= (uint32*)(<font class="keywordtype">void</font>*)ret-1;
+00128 uint32 *checkEnd = (uint32*)((uint8*)(<font class="keywordtype">void</font>*)ret+<a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>);
+00129 <a class="code" href="debug_8h.html#a6">nlassert</a>( *checkStart == <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>);
+00130 <a class="code" href="debug_8h.html#a6">nlassert</a>( *checkEnd == <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>);
+00131 <font class="comment">// if ok, mark this element as allocated.</font>
+00132 *checkStart= <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u0">CheckAllocatedIdent</a>;
+00133 *checkEnd = <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u0">CheckAllocatedIdent</a>;
+00134 <font class="preprocessor">#endif</font>
+00135 <font class="preprocessor"></font>
+00136 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>++;
+00137 <font class="keywordflow">return</font> ret;
+00138 }
+00139
+<a name="l00141"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a4">00141</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a4">free</a>(T* ptr)
+00142 {
+00143 <font class="keywordflow">if</font>(!ptr)
+00144 <font class="keywordflow">return</font>;
+00145 <font class="comment">// some simple Check.</font>
+00146 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>&gt;0);
+00147 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00148 <font class="preprocessor"></font> uint32 *checkStart= (uint32*)(<font class="keywordtype">void</font>*)ptr-1;
+00149 uint32 *checkEnd = (uint32*)((uint8*)(<font class="keywordtype">void</font>*)ptr+<a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>);
+00150 <a class="code" href="debug_8h.html#a6">nlassert</a>( *checkStart == <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u0">CheckAllocatedIdent</a>);
+00151 <a class="code" href="debug_8h.html#a6">nlassert</a>( *checkEnd == <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u0">CheckAllocatedIdent</a>);
+00152 <font class="comment">// if ok, mark this element as deleted.</font>
+00153 *checkStart= <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>;
+00154 *checkEnd = <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>;
+00155 <font class="preprocessor">#endif</font>
+00156 <font class="preprocessor"></font>
+00157 <font class="comment">// destruct the element.</font>
+00158 <font class="keywordflow">if</font>( __ctor_dtor__ )
+00159 ptr-&gt;~T();
+00160
+00161 <font class="comment">// just append this freed element to the list.</font>
+00162 *(<font class="keywordtype">void</font>**)ptr= <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>;
+00163 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= (<font class="keywordtype">void</font>*) ptr;
+00164
+00165 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>--;
+00166 }
+00167
+00168
+<a name="l00174"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a5">00174</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a5">purge</a> ()
+00175 {
+00176 <font class="keywordflow">if</font>(NL3D_BlockMemoryAssertOnPurge)
+00177 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>==0);
+00178
+00179 <font class="keywordflow">while</font>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.begin()!=<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.end())
+00180 {
+00181 <a class="code" href="classNLMISC_1_1CBlockMemory.html#c1">releaseBlock</a>(*<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.begin());
+00182 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.erase(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.begin());
+00183 }
+00184
+00185 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>= NULL;
+00186 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>= 0;
+00187 }
+00188
+00189
+00190 <font class="comment">// ********************</font>
+00191 <font class="keyword">public</font>:
+00192
+00193 <font class="comment">// This is to be used with CSTLBlockAllocator only!!! It change the size of an element!!</font>
+<a name="l00194"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a6">00194</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#a6">__stl_alloc_changeEltSize</a>(uint eltSize)
+00195 {
+00196 <font class="comment">// must not be used with object ctor/dtor behavior.</font>
+00197 <a class="code" href="debug_8h.html#a6">nlassert</a>(__ctor_dtor__ == <font class="keyword">false</font>);
+00198 <font class="comment">// format size.</font>
+00199 eltSize= std::max(eltSize, <font class="keyword">sizeof</font>(<font class="keywordtype">void</font>*));
+00200 <font class="comment">// if not the same size as before</font>
+00201 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>!= eltSize)
+00202 {
+00203 <font class="comment">// verify that rebind is made before any allocation!!</font>
+00204 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>.empty());
+00205 <font class="comment">// change the size.</font>
+00206 <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>= eltSize;
+00207 }
+00208 };
+00209 <font class="comment">// This is to be used with CSTLBlockAllocator only!!!</font>
+<a name="l00210"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#a7">00210</a> uint <a class="code" href="classNLMISC_1_1CBlockMemory.html#a7">__stl_alloc_getEltSize</a>()<font class="keyword"> const</font>
+00211 <font class="keyword"> </font>{
+00212 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>;
+00213 }
+00214
+00215
+00216 <font class="keyword">private</font>:
+<a name="l00218"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">00218</a> uint <a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a>;
+<a name="l00220"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">00220</a> uint <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>;
+<a name="l00222"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">00222</a> sint <a class="code" href="classNLMISC_1_1CBlockMemory.html#o2">_NAllocatedElts</a>;
+<a name="l00224"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">00224</a> <font class="keywordtype">void</font> *<a class="code" href="classNLMISC_1_1CBlockMemory.html#o3">_NextFreeElt</a>;
+00225
+00226
+<a name="l00228"></a><a class="code" href="structNLMISC_1_1CBlockMemory_1_1CBlock.html">00228</a> <font class="keyword">struct </font>CBlock
+00229 {
+<a name="l00231"></a><a class="code" href="structNLMISC_1_1CBlockMemory_1_1CBlock.html#m0">00231</a> <font class="keywordtype">void</font> *<a class="code" href="structNLMISC_1_1CBlockMemory_1_1CBlock.html#m0">Data</a>;
+00232 };
+00233
+<a name="l00235"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">00235</a> <a class="code" href="classstd_1_1list.html">std::list&lt;CBlock&gt;</a> <a class="code" href="classNLMISC_1_1CBlockMemory.html#o4">_Blocks</a>;
+00236
+00237
+<a name="l00239"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#u2">00239</a> <font class="keyword">enum</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2">TCheckIdent</a> { <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u0">CheckAllocatedIdent</a>= 0x01234567, <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>= 0x89ABCDEF };
+00240
+00241
+00242 <font class="keyword">private</font>:
+<a name="l00243"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#c0">00243</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#c0">buildBlock</a>(CBlock &amp;block)
+00244 {
+00245 uint i;
+00246 uint32 nodeSize= <a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>;
+00247 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00248 <font class="preprocessor"></font> <font class="comment">// must allocate more size for mem checks in debug.</font>
+00249 nodeSize+= 2*<font class="keyword">sizeof</font>(uint32);
+00250 <font class="preprocessor">#endif</font>
+00251 <font class="preprocessor"></font>
+00252 <font class="comment">// allocate.</font>
+00253 block.Data = (<font class="keywordtype">void</font>*)<font class="keyword">new</font> uint8 [<a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a> * nodeSize];
+00254
+00255 <font class="comment">// by default, all elements are not allocated, build the list of free elements.</font>
+00256 <font class="keywordtype">void</font> *ptr= block.Data;
+00257 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00258 <font class="preprocessor"></font> <font class="comment">// if debug, must decal for begin check.</font>
+00259 ptr= (uint32*)ptr + 1;
+00260 <font class="preprocessor">#endif</font>
+00261 <font class="preprocessor"></font> <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a>-1; i++)
+00262 {
+00263 <font class="comment">// next elt.</font>
+00264 <font class="keywordtype">void</font> *next= (uint8*)ptr + nodeSize;
+00265 <font class="comment">// points to the next element in this array.</font>
+00266 *(<font class="keywordtype">void</font>**)ptr= next;
+00267 <font class="comment">// next.</font>
+00268 ptr= next;
+00269 }
+00270 <font class="comment">// last element points to NULL.</font>
+00271 *(<font class="keywordtype">void</font>**)ptr= NULL;
+00272
+00273
+00274 <font class="comment">// If debug, must init all check values to CheckDeletedIdent.</font>
+00275 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00276 <font class="preprocessor"></font> ptr= block.Data;
+00277 <font class="comment">// must decal for begin check.</font>
+00278 ptr= (uint32*)ptr + 1;
+00279 <font class="comment">// fill all nodes.</font>
+00280 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNLMISC_1_1CBlockMemory.html#o0">_BlockSize</a>; i++)
+00281 {
+00282 uint32 *checkStart= (uint32*)ptr-1;
+00283 uint32 *checkEnd = (uint32*)((uint8*)ptr+<a class="code" href="classNLMISC_1_1CBlockMemory.html#o1">_EltSize</a>);
+00284 <font class="comment">// mark this element as deleted.</font>
+00285 *checkStart= <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>;
+00286 *checkEnd = <a class="code" href="classNLMISC_1_1CBlockMemory.html#u2u1">CheckDeletedIdent</a>;
+00287
+00288 <font class="comment">// next elt.</font>
+00289 ptr= (uint8*)ptr + nodeSize;
+00290 }
+00291 <font class="preprocessor">#endif</font>
+00292 <font class="preprocessor"></font>
+00293 }
+<a name="l00294"></a><a class="code" href="classNLMISC_1_1CBlockMemory.html#c1">00294</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CBlockMemory.html#c1">releaseBlock</a>(CBlock &amp;block)
+00295 {
+00296 <font class="keyword">delete</font> [] ((uint8*)block.Data);
+00297 }
+00298
+00299 };
+00300
+00301
+00302 } <font class="comment">// NLMISC</font>
+00303
+00304
+00305 <font class="preprocessor">#endif // NL_BLOCK_MEMORY_H</font>
+00306 <font class="preprocessor"></font>
+00307 <font class="comment">/* End of block_memory.h */</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>