Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanMemMngArrayAllocate.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)
17 #define XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
27 
28 
29 
30 XALAN_CPP_NAMESPACE_BEGIN
31 
32 
33 template <class Type>
35 {
36  typedef typename XalanMemMgrAutoPtrArray<Type>::size_type size_type;
37 
38 public:
39  static Type*
40  allocate( size_t size,
41  MemoryManagerType& memoryManager)
42  {
43  XalanMemMgrAutoPtrArray<Type> theGuard ( memoryManager,
44  (Type*)memoryManager.allocate( sizeof(Type)*size),
45  size_type(size) );
46 
47  size_t allocated = 0;
48 
49  for ( Type* runPtr = theGuard.get() ; allocated < size ; ++ allocated )
50  {
51  new ( runPtr + allocated ) Type();
52 
53  ++theGuard;
54  }
55 
56  Type* theResult = theGuard.get();
57 
58  theGuard.release();
59 
60  return theResult;
61  }
62 
63  static Type*
64  allocateMemMgr( size_t size,
65  MemoryManagerType& memoryManager)
66  {
67  XalanMemMgrAutoPtrArray<Type> theGuard ( memoryManager,
68  (Type*)memoryManager.allocate( sizeof(Type)*size),
69  size_type(size) );
70 
71  size_t allocated = 0;
72 
73  for ( Type* runPtr = theGuard.get() ; allocated < size ; ++ allocated )
74  {
75  new ( runPtr + allocated ) Type(memoryManager);
76 
77  ++theGuard;
78  }
79 
80  Type* theResult = theGuard.get();
81 
82  theGuard.release();
83 
84  return theResult;
85  }
86 
87  static void
88  deallocate ( Type* ptr,
89  size_t size,
90  MemoryManagerType& memoryManager)
91  {
92  assert ( ptr != 0 );
93 
94  Type* runPtr = ptr;
95 
96  for ( size_t i = 0; i < size ; ++i )
97  {
98  runPtr->~Type();
99  }
100 
101  memoryManager.deallocate ( ptr);
102  }
103 
104 };
105 
106 
107 XALAN_CPP_NAMESPACE_END
108 
109 
110 
111 #endif // if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)
112 
113 
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
Definition: XalanMemMgrAutoPtr.hpp:219
Definition: XalanMemMngArrayAllocate.hpp:34
static Type * allocateMemMgr(size_t size, MemoryManagerType &memoryManager)
Definition: XalanMemMngArrayAllocate.hpp:64
static Type * allocate(size_t size, MemoryManagerType &memoryManager)
Definition: XalanMemMngArrayAllocate.hpp:40
static void deallocate(Type *ptr, size_t size, MemoryManagerType &memoryManager)
Definition: XalanMemMngArrayAllocate.hpp:88
size_t size_type
Definition: XalanMemMgrAutoPtr.hpp:226
Type * get() const
Definition: XalanMemMgrAutoPtr.hpp:361

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo