FMath/FMAllocator.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
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_

Generated on Thu Feb 14 16:58:34 2008 for FCollada by  doxygen 1.4.6-NO