00001
00002
00003
00004
00005
00006
00007
00008
00014 #ifndef _FM_ALLOCATOR_H_
00015 #define _FM_ALLOCATOR_H_
00016
00017 #include <new>
00018
00019 #ifdef new
00020 #define _OLD_NEW new
00021 #undef new
00022 #endif // new
00023
00024 namespace fm
00025 {
00029 typedef void* (*AllocateFunc)(size_t size);
00030
00033 typedef void (*FreeFunc)(void* buffer);
00034
00038 FCOLLADA_EXPORT void SetAllocationFunctions(AllocateFunc a, FreeFunc f);
00039
00044 FCOLLADA_EXPORT void* Allocate(size_t byteCount);
00045
00048 FCOLLADA_EXPORT void Release(void* buffer);
00049
00052 template <class Type1>
00053 inline void Construct(Type1* o)
00054 {
00055 ::new (o) Type1;
00056 }
00057
00061 template <class Type1, class Type2>
00062 inline void Construct(Type1* o, const Type2& value)
00063 {
00064 ::new (o) Type1(value);
00065 }
00066 };
00067
00068 #ifdef _OLD_NEW
00069 #define new _OLD_NEW
00070 #undef _OLD_NEW
00071 #endif // _OLD_NEW
00072
00073 #endif // _FM_ALLOCATOR_H_