src/core/alloc_func.hpp
author rubidium
Wed, 16 Jul 2008 16:05:52 +0000
branch0.6
changeset 11152 b56fd5acecaf
parent 9033 7153b87990f8
child 9294 5cd9e0da420f
permissions -rw-r--r--
(svn r13710) [0.6] -Prepare: for 0.6.2-RC1.
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     1
/* $Id$ */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     2
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
     3
/** @file alloc_func.hpp Functions related to the allocation of memory */
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6482
diff changeset
     4
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
     5
#ifndef ALLOC_FUNC_HPP
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
     6
#define ALLOC_FUNC_HPP
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     7
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
     8
/**
9033
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
     9
 * Functions to exit badly with an error message.
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    10
 * It has to be linked so the error messages are not
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    11
 * duplicated in each object file making the final
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    12
 * binary needlessly large.
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    13
 */
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    14
void MallocError(size_t size);
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    15
void ReallocError(size_t size);
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    16
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    17
/**
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    18
 * Simplified allocation function that allocates the specified number of
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    19
 * elements of the given type. It also explicitly casts it to the requested
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    20
 * type.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    21
 * @note throws an error when there is no memory anymore.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    22
 * @note the memory contains garbage data (i.e. possibly non-zero values).
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    23
 * @param T the type of the variable(s) to allocation.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    24
 * @param num_elements the number of elements to allocate of the given type.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    25
 * @return NULL when num_elements == 0, non-NULL otherwise.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    26
 */
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
    27
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    28
{
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    29
	/*
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    30
	 * MorphOS cannot handle 0 elements allocations, or rather that always
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    31
	 * returns NULL. So we do that for *all* allocations, thus causing it
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    32
	 * to behave the same on all OSes.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    33
	 */
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    34
	if (num_elements == 0) return NULL;
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    35
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
    36
	T *t_ptr = (T*)malloc(num_elements * sizeof(T));
9033
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    37
	if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
    38
	return t_ptr;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    39
}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    40
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    41
/**
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    42
 * Simplified allocation function that allocates the specified number of
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    43
 * elements of the given type. It also explicitly casts it to the requested
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    44
 * type.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    45
 * @note throws an error when there is no memory anymore.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    46
 * @note the memory contains all zero values.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    47
 * @param T the type of the variable(s) to allocation.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    48
 * @param num_elements the number of elements to allocate of the given type.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    49
 * @return NULL when num_elements == 0, non-NULL otherwise.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    50
 */
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    51
template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    52
{
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    53
	/*
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    54
	 * MorphOS cannot handle 0 elements allocations, or rather that always
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    55
	 * returns NULL. So we do that for *all* allocations, thus causing it
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    56
	 * to behave the same on all OSes.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    57
	 */
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    58
	if (num_elements == 0) return NULL;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    59
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    60
	T *t_ptr = (T*)calloc(num_elements, sizeof(T));
9033
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    61
	if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    62
	return t_ptr;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    63
}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    64
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    65
/**
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    66
 * Simplified reallocation function that allocates the specified number of
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    67
 * elements of the given type. It also explicitly casts it to the requested
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    68
 * type. It extends/shrinks the memory allocation given in t_ptr.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    69
 * @note throws an error when there is no memory anymore.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    70
 * @note the memory contains all zero values.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    71
 * @param T the type of the variable(s) to allocation.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    72
 * @param t_ptr the previous allocation to extend/shrink.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    73
 * @param num_elements the number of elements to allocate of the given type.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    74
 * @return NULL when num_elements == 0, non-NULL otherwise.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    75
 */
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    76
template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    77
{
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    78
	/*
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    79
	 * MorphOS cannot handle 0 elements allocations, or rather that always
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    80
	 * returns NULL. So we do that for *all* allocations, thus causing it
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    81
	 * to behave the same on all OSes.
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    82
	 */
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    83
	if (num_elements == 0) {
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    84
		free(t_ptr);
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    85
		return NULL;
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    86
	}
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    87
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    88
	t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
9033
7153b87990f8 (svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
smatz
parents: 8872
diff changeset
    89
	if (t_ptr == NULL) ReallocError(num_elements * sizeof(T));
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    90
	return t_ptr;
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    91
}
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
    92
8872
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    93
/**
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    94
 * A small 'wrapper' for allocations that can be done on most OSes on the
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    95
 * stack, but are just too large to fit in the stack on devices with a small
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    96
 * stack such as the NDS.
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    97
 * So when it is possible a stack allocation is made, otherwise a heap
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    98
 * allocation is made and this is freed once the struct goes out of scope.
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
    99
 * @param T      the type to make the allocation for
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   100
 * @param length the amount of items to allocate
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   101
 */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   102
template <typename T, size_t length>
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   103
struct SmallStackSafeStackAlloc {
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   104
#if !defined(__NDS__)
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   105
	/** Storing the data on the stack */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   106
	T data[length];
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   107
#else
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   108
	/** Storing it on the heap */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   109
	T *data;
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   110
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   111
	/** Allocating the memory */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   112
	SmallStackSafeStackAlloc() : data(MallocT<T>(length)) {}
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   113
	/** And freeing when it goes out of scope */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   114
	~SmallStackSafeStackAlloc() { free(data); }
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   115
#endif
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   116
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   117
	/**
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   118
	 * Gets a pointer to the data stored in this wrapper.
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   119
	 * @return the pointer.
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   120
	 */
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   121
	operator T* () { return data; }
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   122
};
dd23eb1922b6 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8626
diff changeset
   123
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8608
diff changeset
   124
#endif /* ALLOC_FUNC_HPP */