2003-06-23 09:55:31 +04:00
|
|
|
#ifndef _MALLOC_FREE_ALLOCATOR_H_
|
|
|
|
#define _MALLOC_FREE_ALLOCATOR_H_
|
|
|
|
|
2007-08-11 18:57:25 +04:00
|
|
|
#include <util/Constructor.h>
|
2003-06-23 09:55:31 +04:00
|
|
|
|
|
|
|
#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;
|
2015-07-05 12:41:32 +03:00
|
|
|
|
2003-06-23 09:55:31 +04:00
|
|
|
/*! malloc()'s an object of type \c DataType and returns a
|
|
|
|
pointer to it.
|
|
|
|
*/
|
|
|
|
Pointer Allocate() {
|
|
|
|
return reinterpret_cast<Pointer>(malloc(sizeof(DataType)));
|
|
|
|
}
|
2015-07-05 12:41:32 +03:00
|
|
|
|
2003-06-23 09:55:31 +04:00
|
|
|
/*! free()'s the given object.
|
|
|
|
*/
|
|
|
|
void Deallocate(Pointer object) {
|
|
|
|
free(object);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _MALLOC_FREE_ALLOCATOR_H_
|