an efficient C++ finite element environment
|
|
Go to the documentation of this file. 1 #ifndef _RHEOLEF_HEAP_ALLOCATOR_H
2 #define _RHEOLEF_HEAP_ALLOCATOR_H
26 #include "rheolef/compiler.h"
27 #include "rheolef/pretty_name.h"
62 #define _RHEOLEF_DO_NOT_USE_HEAP_ALLOCATOR
63 #ifdef _RHEOLEF_DO_NOT_USE_HEAP_ALLOCATOR
65 #else // _RHEOLEF_DO_NOT_USE_HEAP_ALLOCATOR
107 template <
typename U>
132 new(
reinterpret_cast<void*
>(
p) )
T(
c);
166 template <
typename T1>
169 return lhs.get_handler() == rhs.get_handler();
171 template <
typename T1>
174 return lhs.get_handler() != rhs.get_handler();
187 unsigned char* raw_allocate (
size_type size);
189 std::list<std::vector<unsigned char> >
heap;
199 heap_block_size (heap_block_size_init),
200 heap_block_last_free (0),
210 if (heap_block_last_free + size > heap_block_size) {
211 heap_block_size = std::max (size, 2*heap_block_size);
212 heap.push_front (std::vector<unsigned char>(heap_block_size));
213 heap_block_last_free = 0;
215 std::vector<unsigned char>& block = *(heap.begin());
216 unsigned char*
p = &(block [heap_block_last_free]);
217 heap_block_last_free += size;
224 heap.erase (heap.begin(), heap.end());
227 #endif // _RHEOLEF_DO_NOT_USE_HEAP_ALLOCATOR
230 #endif // _RHEOLEF_HEAP_ALLOCATOR_H
void deallocate(pointer p, size_type n)
size_type heap_block_size
const handler_type * get_handler() const
bool operator!=(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
heap_allocator(const heap_allocator< U > &ha)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
heap_allocator(const heap_allocator &ha)
pointer address(reference r) const
unsigned char * raw_allocate(size_type size)
heap_allocator< U > other
bool operator==(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
size_type reference_count
pointer allocate(size_type n, const void *=NULL)
std::ptrdiff_t difference_type
This file is part of Rheolef.
size_type heap_block_last_free
size_type max_size() const
const_pointer address(const_reference c) const
void construct(pointer p, const_reference c)
heap_allocator & operator=(const heap_allocator &ha)
void construct(pointer p)
std::list< std::vector< unsigned char > > heap
const T & const_reference