blob: 5a03514b4f267df8209fa968f0080330d57c0fa2 [file] [log] [blame]
<HTML><HEAD><TITLE>Xalan-C++ API Documentation</TITLE></HEAD>
<BODY>
<h2 align="center">Xalan-C++ API Documentation</h2>
<h3 align="center">The Xalan C++ XSLT Processor Version 1.10</h3>
</BODY>
<!-- Generated by Doxygen 1.2.8.1 -->
<center>
<a class="qindex" href="index.html">Main Page</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="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>XalanMemMngArrayAllocate.hpp</h1><a href="XalanMemMngArrayAllocate_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>
00002 <font class="comment"> * Copyright 1999-2004 The Apache Software Foundation.</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</font>
00005 <font class="comment"> * you may not use this file except in compliance with the License.</font>
00006 <font class="comment"> * You may obtain a copy of the License at</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</font>
00009 <font class="comment"> *</font>
00010 <font class="comment"> * Unless required by applicable law or agreed to in writing, software</font>
00011 <font class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</font>
00012 <font class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</font>
00013 <font class="comment"> * See the License for the specific language governing permissions and</font>
00014 <font class="comment"> * limitations under the License.</font>
00015 <font class="comment"> */</font>
00016 <font class="preprocessor">#if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)</font>
<a name="l00017"></a><a class="code" href="XalanMemMngArrayAllocate_8hpp.html#a0">00017</a> <font class="preprocessor"></font><font class="preprocessor">#define XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680</font>
00018 <font class="preprocessor"></font>
00019
00020
00021 <font class="comment">// Base include file. Must be first.</font>
00022 <font class="preprocessor">#include &lt;<a class="code" href="PlatformSupportDefinitions_8hpp.html">xalanc/PlatformSupport/PlatformSupportDefinitions.hpp</a>&gt;</font>
00023
00024
00025
00026 <font class="preprocessor">#include &lt;<a class="code" href="XalanMemMgrAutoPtr_8hpp.html">xalanc/Include/XalanMemMgrAutoPtr.hpp</a>&gt;</font>
00027
00028
00029
00030 XALAN_CPP_NAMESPACE_BEGIN
00031
00032
00033 template &lt;class Type&gt;
<a name="l00034"></a><a class="code" href="classXalanMemMngArrayAllocate.html">00034</a> <font class="keyword">class </font><a class="code" href="classXalanMemMngArrayAllocate.html">XalanMemMngArrayAllocate</a>
00035 {
00036 <font class="keyword">typedef</font> <font class="keyword">typename</font> <a class="code" href="classXalanMemMgrAutoPtrArray.html">XalanMemMgrAutoPtrArray&lt;Type&gt;</a>::size_type size_type;
00037
00038 <font class="keyword">public</font>:
00039 <font class="keyword">static</font> Type*
<a name="l00040"></a><a class="code" href="classXalanMemMngArrayAllocate.html#d0">00040</a> <a class="code" href="classXalanMemMngArrayAllocate.html#d0">allocate</a>( size_t size,
00041 MemoryManagerType&amp; memoryManager)<font class="keyword"></font>
00042 <font class="keyword"> </font>{
00043 <a class="code" href="classXalanMemMgrAutoPtrArray.html">XalanMemMgrAutoPtrArray&lt;Type&gt;</a> theGuard ( memoryManager,
00044 (Type*)memoryManager.allocate( <font class="keyword">sizeof</font>(Type)*size),
00045 <a class="code" href="XalanMap_8hpp.html#a1">size_type</a>(size) );
00046
00047 size_t allocated = 0;
00048
00049 <font class="keywordflow">for</font> ( Type* runPtr = theGuard.get() ; allocated &lt; size ; ++ allocated )
00050 {
00051 <font class="keyword">new</font> ( runPtr + allocated ) Type();
00052
00053 ++theGuard;
00054 }
00055
00056 Type* theResult = theGuard.get();
00057
00058 theGuard.release();
00059
00060 <font class="keywordflow">return</font> theResult;
00061 }
00062
00063 <font class="keyword">static</font> Type*
<a name="l00064"></a><a class="code" href="classXalanMemMngArrayAllocate.html#d1">00064</a> <a class="code" href="classXalanMemMngArrayAllocate.html#d1">allocateMemMgr</a>( size_t size,
00065 MemoryManagerType&amp; memoryManager)<font class="keyword"></font>
00066 <font class="keyword"> </font>{
00067 <a class="code" href="classXalanMemMgrAutoPtrArray.html">XalanMemMgrAutoPtrArray&lt;Type&gt;</a> theGuard ( memoryManager,
00068 (Type*)memoryManager.allocate( <font class="keyword">sizeof</font>(Type)*size),
00069 <a class="code" href="XalanMap_8hpp.html#a1">size_type</a>(size) );
00070
00071 size_t allocated = 0;
00072
00073 <font class="keywordflow">for</font> ( Type* runPtr = theGuard.get() ; allocated &lt; size ; ++ allocated )
00074 {
00075 <font class="keyword">new</font> ( runPtr + allocated ) Type(memoryManager);
00076
00077 ++theGuard;
00078 }
00079
00080 Type* theResult = theGuard.get();
00081
00082 theGuard.release();
00083
00084 <font class="keywordflow">return</font> theResult;
00085 }
00086
00087 <font class="keyword">static</font> <font class="keywordtype">void</font>
<a name="l00088"></a><a class="code" href="classXalanMemMngArrayAllocate.html#d2">00088</a> <a class="code" href="classXalanMemMngArrayAllocate.html#d2">deallocate</a> ( Type* ptr,
00089 size_t size,
00090 MemoryManagerType&amp; memoryManager)<font class="keyword"></font>
00091 <font class="keyword"> </font>{
00092 assert ( ptr != 0 );
00093
00094 Type* runPtr = ptr;
00095
00096 <font class="keywordflow">for</font> ( size_t i = 0; i &lt; size ; ++i )
00097 {
00098 runPtr-&gt;~Type();
00099 }
00100
00101 memoryManager.deallocate ( ptr);
00102 }
00103
00104 };
00105
00106
00107 XALAN_CPP_NAMESPACE_END
00108
00109
00110
00111 <font class="preprocessor">#endif // if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)</font>
00112 <font class="preprocessor"></font>
00113
</pre></div><p align="center"><a href="diagramnotes.html">Interpreting class diagrams</a></p>
<p><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<i><A href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</A> and
<A href="http://www.research.att.com/sw/tools/graphviz/">GraphViz</A> are used to generate this API documentation from the Xalan-C header files.</I></FONT></p>
<TABLE border="0" cellpadding="0" cellspacing="0" width="820"><TR><TD bgcolor="#0086b2"><IMG height="1" src="../resources/dot.gif" width="1" alt="dot"></TD></TR></TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80%">
<TR>
<TD WIDTH="80%" VALIGN="TOP">
<P ALIGN="CENTER"><B>Xalan-C++ XSLT Processor Version 1.10</B><BR>
Copyright &copy; 1999-2004 The Apache Software Foundation. All Rights Reserved.</i></p>
</TD>
</TR>
<TR>
<TD WIDTH="100%">
<P ALIGN="CENTER"><IMG SRC="ApacheLogo.jpg" WIDTH="387" HEIGHT="100" ALIGN="BOTTOM" BORDER="0" ALT="Apache Logo">
</TD>
</TR>
</TABLE>