mbo::mem_reallocator< __ValueType > Class Template Reference

Allocator that supports reallocation working on malloc(). More...

#include <reallocator.h>

Inheritance diagram for mbo::mem_reallocator< __ValueType >:

Inheritance graph
{mbo::reallocator\< __ValueType \>\n||+ reallocate()\l+ move()\l}{mbo::allocator\< __ValueType \>\n||+ address()\l+ address()\l+ allocate()\l+ deallocate()\l+ construct()\l+ max_size()\l}{mbo::allocator\< __ValueType, __ReferenceType \>\n||+ address()\l+ address()\l+ allocate()\l+ deallocate()\l+ construct()\l+ max_size()\l}
[legend]
Collaboration diagram for mbo::mem_reallocator< __ValueType >:

Collaboration graph
{mbo::reallocator\< __ValueType \>\n||+ reallocate()\l+ move()\l}{mbo::allocator\< __ValueType \>\n||+ address()\l+ address()\l+ allocate()\l+ deallocate()\l+ construct()\l+ max_size()\l}{mbo::allocator\< __ValueType, __ReferenceType \>\n||+ address()\l+ address()\l+ allocate()\l+ deallocate()\l+ construct()\l+ max_size()\l}
[legend]

List of all members.

Public Member Functions

pointer allocate (size_type size, std::allocator< void >::const_pointer hint=0L)
void deallocate (pointer ptr, size_type)
pointer reallocate (pointer ptr, size_type, size_type new_size)
void move (pointer dst, pointer src, size_type size)


Detailed Description

template<class __ValueType>
class mbo::mem_reallocator< __ValueType >

Allocator that supports reallocation working on malloc().

This allocator uses malloc(), realloc() and free() directly for elements space allocation/reallocation/deallocation.

This allocator uses memmove() directly when reallocating element space to copy elements from the orignal location to the new location without the need to call constructors and destructors (not even inplace destructors).

See also:
TDynamicArray

MBO_THROWS_EXCEPTIONS

Definition at line 232 of file reallocator.h.


Member Function Documentation

template<class __ValueType>
pointer mbo::mem_reallocator< __ValueType >::allocate ( size_type  size,
std::allocator< void >::const_pointer  hint = 0L 
) [inline]

Use malloc() to allocate size number of uninitialized elements

Parameters:
size number of elements to allocate
hint ignored here
Returns:
pointer to the allocated memory

Definition at line 242 of file reallocator.h.

References mbo_malloc.

00243     {
00244         return static_cast<pointer>(mbo_malloc(size * sizeof(value_type)));
00245     }

template<class __ValueType>
void mbo::mem_reallocator< __ValueType >::deallocate ( pointer  ptr,
size_type   
) [inline]

Frees an element space

Parameters:
ptr original pointer
size number of elements (ignored)
Warning:
calls free(ptr) directly)

Definition at line 254 of file reallocator.h.

00255     {
00256         free(ptr);
00257     }

template<class __ValueType>
pointer mbo::mem_reallocator< __ValueType >::reallocate ( pointer  ptr,
size_type  ,
size_type  new_size 
) [inline]

Reallocate element space using realloc()

Parameters:
ptr original pointer
old_size original number of elements (ignored)
new_size new number of elements
Returns:
reallocated element space
Warning:
Calls realloc(ptr, new_size * sizeof(value_type)) directly.
Note:
Does not use move().

Reimplemented from mbo::reallocator< __ValueType >.

Definition at line 269 of file reallocator.h.

References mbo_realloc.

00270     {
00271         return static_cast<pointer>(mbo_realloc(ptr, new_size * sizeof(value_type)));
00272     }

template<class __ValueType>
void mbo::mem_reallocator< __ValueType >::move ( pointer  dst,
pointer  src,
size_type  size 
) [inline]

Moves size elements from src to dst using memmove()

Parameters:
dst destination pointer
src source pointer
size number of elements to move
Warning:
Calls malloc(dst, src, size * sizeof(value_type)) directly.

Reimplemented from mbo::reallocator< __ValueType >.

Definition at line 282 of file reallocator.h.

00283     {
00284         memmove(dst, src, size * sizeof(value_type));
00285     }


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:13 2008 for MBO-lib by doxygen 1.5.4