CrystalSpace

Public API Reference

CS::Memory::AllocatorNew< T > Class Template Reference

A default memory allocator that allocates using new T[]. More...

#include <csutil/allocator.h>

List of all members.

Public Member Functions

void * Alloc (const size_t n)
 Allocate a block of memory of size n.
void Free (void *p)
 Free the block p.
void * Realloc (void *p, size_t newSize)
 Resize the allocated block p to size newSize.
void SetMemTrackerInfo (const char *)
 Set the information used for memory tracking.


Detailed Description

template<typename T>
class CS::Memory::AllocatorNew< T >

A default memory allocator that allocates using new T[].

Warning:
Using this allocator is somewhat dangerous, as an array of Ts to fit the requested size is allocated, and the array is casted to a void*. Using anything but POD types is irresponsible. Don't use this allocator unless you really, really have to - for example, when memory is passed from/to code which uses new[]/delete[] of T for allocation/deallocation.
Remarks:
Reallocatability is inherently unsupported.

Definition at line 330 of file allocator.h.


Member Function Documentation

template<typename T>
void* CS::Memory::AllocatorNew< T >::Alloc ( const size_t  n  )  [inline]

Allocate a block of memory of size n.

Definition at line 334 of file allocator.h.

template<typename T>
void CS::Memory::AllocatorNew< T >::Free ( void *  p  )  [inline]

Free the block p.

Definition at line 339 of file allocator.h.

template<typename T>
void* CS::Memory::AllocatorNew< T >::Realloc ( void *  p,
size_t  newSize 
) [inline]

Resize the allocated block p to size newSize.

Definition at line 344 of file allocator.h.

References CS_ASSERT_MSG.

template<typename T>
void CS::Memory::AllocatorNew< T >::SetMemTrackerInfo ( const char *   )  [inline]

Set the information used for memory tracking.

Definition at line 350 of file allocator.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space 1.2.1 by doxygen 1.5.3