SmallStackSafeStackAlloc< T, length > Struct Template Reference

A small 'wrapper' for allocations that can be done on most OSes on the stack, but are just too large to fit in the stack on devices with a small stack such as the NDS. More...

#include <alloc_type.hpp>

Public Member Functions

FORCEINLINE operator T * ()
 Gets a pointer to the data stored in this wrapper.
FORCEINLINE T * operator-> ()
 Gets a pointer to the data stored in this wrapper.
FORCEINLINE T * EndOf ()
 Gets a pointer to the last data element stored in this wrapper.

Data Fields

data [length]
 Storing the data on the stack.

Detailed Description

template<typename T, size_t length>
struct SmallStackSafeStackAlloc< T, length >

A small 'wrapper' for allocations that can be done on most OSes on the stack, but are just too large to fit in the stack on devices with a small stack such as the NDS.

So when it is possible a stack allocation is made, otherwise a heap allocation is made and this is freed once the struct goes out of scope.

Parameters:
T the type to make the allocation for
length the amount of items to allocate

Definition at line 27 of file alloc_type.hpp.


Member Function Documentation

template<typename T, size_t length>
FORCEINLINE T* SmallStackSafeStackAlloc< T, length >::EndOf (  )  [inline]

Gets a pointer to the last data element stored in this wrapper.

Note:
needed because endof does not work properly for pointers.
Returns:
the 'endof' pointer.

Definition at line 70 of file alloc_type.hpp.

References SmallStackSafeStackAlloc< T, length >::data, and endof.

template<typename T, size_t length>
FORCEINLINE SmallStackSafeStackAlloc< T, length >::operator T * (  )  [inline]

Gets a pointer to the data stored in this wrapper.

Returns:
the pointer.

Definition at line 51 of file alloc_type.hpp.

References SmallStackSafeStackAlloc< T, length >::data.

template<typename T, size_t length>
FORCEINLINE T* SmallStackSafeStackAlloc< T, length >::operator-> (  )  [inline]

Gets a pointer to the data stored in this wrapper.

Returns:
the pointer.

Definition at line 60 of file alloc_type.hpp.

References SmallStackSafeStackAlloc< T, length >::data.


The documentation for this struct was generated from the following file:

Generated on Sun Jan 9 16:03:21 2011 for OpenTTD by  doxygen 1.6.1