haiku/headers/private/kernel/util/MallocFreeAllocator.h
Ingo Weinhold 2529455101 Revised the AVLTreeMap code:
* Pulled the actual tree code into a non-templatized class AVLTree to
  reduce the amount of code generated each time the template is
  instantiated.
* Changed the iterator interface to Java-style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21892 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-11 14:57:25 +00:00

31 lines
654 B
C++

#ifndef _MALLOC_FREE_ALLOCATOR_H_
#define _MALLOC_FREE_ALLOCATOR_H_
#include <util/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_