diff --git a/headers/private/kernel/util/MallocFreeAllocator.h b/headers/private/kernel/util/MallocFreeAllocator.h new file mode 100644 index 0000000000..6489648cc2 --- /dev/null +++ b/headers/private/kernel/util/MallocFreeAllocator.h @@ -0,0 +1,30 @@ +#ifndef _MALLOC_FREE_ALLOCATOR_H_ +#define _MALLOC_FREE_ALLOCATOR_H_ + +#include "Constructor.h" + +#include + +template +class MallocFreeAllocator : public Constructor { +public: + typedef DataType* Pointer; + typedef const DataType* ConstPointer; + typedef DataType& Reference; + typedef const DataType& ConstReference; + + /*! malloc()'s an object of type \c DataType and returns a + pointer to it. + */ + Pointer Allocate() { + return reinterpret_cast(malloc(sizeof(DataType))); + } + + /*! free()'s the given object. + */ + void Deallocate(Pointer object) { + free(object); + } +}; + +#endif // _MALLOC_FREE_ALLOCATOR_H_