btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / kernel / util / MallocFreeAllocator.h
blob12eb665c0c4438af47df7ae789537c64fcd1c3bf
1 #ifndef _MALLOC_FREE_ALLOCATOR_H_
2 #define _MALLOC_FREE_ALLOCATOR_H_
4 #include <util/Constructor.h>
6 #include <malloc.h>
8 template <class DataType>
9 class MallocFreeAllocator : public Constructor<DataType> {
10 public:
11 typedef DataType* Pointer;
12 typedef const DataType* ConstPointer;
13 typedef DataType& Reference;
14 typedef const DataType& ConstReference;
16 /*! malloc()'s an object of type \c DataType and returns a
17 pointer to it.
19 Pointer Allocate() {
20 return reinterpret_cast<Pointer>(malloc(sizeof(DataType)));
23 /*! free()'s the given object.
25 void Deallocate(Pointer object) {
26 free(object);
30 #endif // _MALLOC_FREE_ALLOCATOR_H_