diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index e7eaf1d84..75a5cb377 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -194,7 +194,7 @@ SET( Common_SRCS Common/ScenePreprocessor.h Common/SkeletonMeshBuilder.cpp Common/StackAllocator.h - Common/StackAllocator.cpp + Common/StackAllocator.inl Common/StandardShapes.cpp Common/TargetAnimation.cpp Common/TargetAnimation.h diff --git a/code/Common/StackAllocator.h b/code/Common/StackAllocator.h index cc252f8df..aff36fa47 100644 --- a/code/Common/StackAllocator.h +++ b/code/Common/StackAllocator.h @@ -64,9 +64,9 @@ namespace Assimp class StackAllocator { public: // Constructs the allocator - StackAllocator(); + inline StackAllocator(); // Destructs the allocator and frees all memory - ~StackAllocator(); + inline ~StackAllocator(); // non copyable StackAllocator(const StackAllocator &) = delete; @@ -74,11 +74,11 @@ public: // Returns a pointer to byteSize bytes of heap memory that persists // for the lifetime of the allocator (or until FreeAll is called). - void *Allocate(size_t byteSize); + inline void *Allocate(size_t byteSize); // Releases all the memory owned by this allocator. // Memory provided through function Allocate is not valid anymore after this function has been called. - void FreeAll(); + inline void FreeAll(); private: constexpr const static size_t g_maxBytesPerBlock = 64 * 1024 * 1024; // The maximum size (in bytes) of a block @@ -91,4 +91,6 @@ private: } // namespace Assimp +#include "StackAllocator.inl" + #endif // include guard diff --git a/code/Common/StackAllocator.cpp b/code/Common/StackAllocator.inl similarity index 93% rename from code/Common/StackAllocator.cpp rename to code/Common/StackAllocator.inl index 259a565be..d973b7794 100644 --- a/code/Common/StackAllocator.cpp +++ b/code/Common/StackAllocator.inl @@ -46,14 +46,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; -StackAllocator::StackAllocator() { +inline StackAllocator::StackAllocator() { } -StackAllocator::~StackAllocator() { +inline StackAllocator::~StackAllocator() { FreeAll(); } -void *StackAllocator::Allocate(size_t byteSize) { +inline void *StackAllocator::Allocate(size_t byteSize) { if (m_subIndex + byteSize > m_blockAllocationSize) // start a new block { // double block size every time, up to maximum of g_maxBytesPerBlock. @@ -72,7 +72,7 @@ void *StackAllocator::Allocate(size_t byteSize) { return data; } -void StackAllocator::FreeAll() { +inline void StackAllocator::FreeAll() { for (size_t i = 0; i < m_storageBlocks.size(); i++) { delete [] m_storageBlocks[i]; }