Allocator that uses malloc()/free()

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3622 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2003-06-23 05:55:31 +00:00
parent e9ebb4a961
commit ab608058b4
@@ -0,0 +1,30 @@
#ifndef _MALLOC_FREE_ALLOCATOR_H_
#define _MALLOC_FREE_ALLOCATOR_H_
#include "Constructor.h"
#include <malloc.h>
template <class DataType>
class MallocFreeAllocator : public Constructor<DataType> {
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<Pointer>(malloc(sizeof(DataType)));
}
/*! free()'s the given object.
*/
void Deallocate(Pointer object) {
free(object);
}
};
#endif // _MALLOC_FREE_ALLOCATOR_H_