Codechange: Replace SmallStackSafeStackAlloc with std::array.

The only port that ever used it to make heap allocations instead of stack ones was the NDS port, which got thrown out some time ago.
This commit is contained in:
Michael Lutz
2019-04-14 16:28:08 +02:00
committed by Charles Pigott
parent 79343762a4
commit 4e85ccf3c0
3 changed files with 49 additions and 90 deletions

View File

@@ -14,49 +14,6 @@
#include "alloc_func.hpp"
/**
* 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.
* @param T the type to make the allocation for
* @param length the amount of items to allocate
*/
template <typename T, size_t length>
struct SmallStackSafeStackAlloc {
/** Storing the data on the stack */
T data[length];
/**
* Gets a pointer to the data stored in this wrapper.
* @return the pointer.
*/
inline operator T *()
{
return data;
}
/**
* Gets a pointer to the data stored in this wrapper.
* @return the pointer.
*/
inline T *operator -> ()
{
return data;
}
/**
* Gets a pointer to the last data element stored in this wrapper.
* @note needed because endof does not work properly for pointers.
* @return the 'endof' pointer.
*/
inline T *EndOf()
{
return endof(data);
}
};
/**
* A reusable buffer that can be used for places that temporary allocate
* a bit of memory and do that very often, or for places where static