20 #ifndef _FBXSDK_CORE_ARCH_ALLOC_H_
21 #define _FBXSDK_CORE_ARCH_ALLOC_H_
25 #if defined(_DEBUG) && defined(FBXSDK_ENV_WIN)
29 #if defined(FBXSDK_ENV_MAC)
30 #include <malloc/malloc.h>
37 #if defined(FBXSDK_CPU_32) && !defined(FBXSDK_ENV_IOS)
38 #define FBXSDK_MEMORY_ALIGNMENT ((size_t)8U)
40 #define FBXSDK_MEMORY_ALIGNMENT ((size_t)16U)
43 #define FBXSDK_MEMORY_COPY(dst, src, size) {memcpy(dst,src,size);}
45 typedef void* (*FbxMallocProc)(size_t);
46 typedef void* (*FbxCallocProc)(size_t, size_t);
47 typedef void* (*FbxReallocProc)(
void*, size_t);
101 #ifndef DOXYGEN_SHOULD_SKIP_THIS
103 FBXSDK_DLL void* FbxCalloc(
size_t pCount,
size_t pSize);
104 FBXSDK_DLL void* FbxRealloc(
void* pData,
size_t pSize);
106 FBXSDK_DLL char* FbxStrDup(
const char* pString);
107 FBXSDK_DLL wchar_t* FbxStrDupWC(
const wchar_t* pString);
111 FBXSDK_DLL void* FbxMallocDebug(
size_t pSize,
int pBlock,
const char* pFile,
int pLine);
112 FBXSDK_DLL void* FbxCallocDebug(
size_t pCount,
size_t pSize,
int pBlock,
const char* pFile,
int pLine);
113 FBXSDK_DLL void* FbxReallocDebug(
void* pData,
size_t pSize,
int pBlock,
const char* pFile,
int pLine);
114 FBXSDK_DLL void FbxFreeDebug(
void* pData,
int pBlock);
117 #if defined(FBXSDK_ALLOC_DEBUG)
118 #define FbxMalloc(s) FbxMallocDebug(s, _NORMAL_BLOCK, __FILE__, __LINE__)
119 #define FbxCalloc(c, s) FbxCallocDebug(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
120 #define FbxRealloc(p, s) FbxReallocDebug(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
121 #define FbxFree(p) FbxFreeDebug(p, _NORMAL_BLOCK)
188 template<
class Type,
class Policy=FbxDeletionPolicyDefault<Type> >
class FbxAutoPtr
198 inline Type*
Get()
const {
return mPtr; }
204 inline operator Type* ()
const {
return mPtr; }
213 inline operator bool ()
const {
return mPtr != 0; }
218 FBX_ASSERT(pPtr == 0 || pPtr != mPtr);
225 Type* TmpPtr = pOther.mPtr;
241 #ifndef DOXYGEN_SHOULD_SKIP_THIS
286 int DecRef() { count--;
if (count < 0) count = 0;
return count; }
292 template<
class Type,
class Policy=FbxDeletionPolicyDefault<Type> >
class FbxSharedPtr
319 if (pSPtr.mPtr != 0 && mRef != 0)
334 FBX_ASSERT(mRef !=
NULL);
347 inline Type*
Get()
const {
return mPtr; }
353 inline operator Type* ()
const {
return mPtr; }
362 inline operator bool ()
const {
return mPtr != 0; }
368 #ifndef DOXYGEN_SHOULD_SKIP_THIS
374 FBX_ASSERT(mPtr != 0);
375 if (mRef->DecRef() == 0)
377 Policy::DeleteIt(&mPtr);
void Reset(Type *pPtr=0)
Reset the scoped pointer by swapping with another pointer.
FbxAutoPtr mimics the auto_ptr class template implementation available in the C++ Standard Library...
FbxSharedDestroyPtr(Type *pPtr=0)
Construct from a pointer.
FBX SDK environment definition.
FbxSharedPtr(Type *pPtr)
Construct from a pointer.
Type * Get() const
Retrieve the pointer it holds.
Deletion policy for pointer template classes that uses the FbxDelete() function.
Deletion policy for pointer template classes that uses the FbxFree() function.
FBXSDK_DLL FbxFreeProc FbxGetFreeHandler()
Get the global memory freeing function used internally by the FBX SDK.
FbxSharedPtr class describes an object that stores a pointer to a single allocated object of type Typ...
FbxSharedPtr(const FbxSharedPtr &pSPtr)
Copy constructor.
FBXSDK_DLL FbxReallocProc FbxGetDefaultReallocHandler()
Get the default global memory re-allocation function used internally by the FBX SDK.
FBXSDK_DLL FbxMallocProc FbxGetMallocHandler()
Get the global memory allocation function used internally by the FBX SDK.
~FbxSharedPtr()
Destructor.
Type * operator->() const
Member access operator.
static void DeleteIt(Type **pPtr)
Destruction policy implementation.
FbxAutoDeletePtr(Type *pPtr=0)
Construct from a pointer.
void(* FbxFreeProc)(void *)
Function pointer signature used to replace "realloc".
Deletion policy for pointer template classes that uses the Destroy() function.
FbxAutoDestroyPtr(Type *pPtr=0)
Construct from a pointer.
Type * Get() const
Retrieve the pointer it holds.
FbxSharedDeletePtr(Type *pPtr=0)
Construct from a pointer.
FBXSDK_DLL FbxReallocProc FbxGetReallocHandler()
Get the global memory re-allocation function used internally by the FBX SDK.
static void DeleteIt(Type **pPtr)
Destruction policy implementation.
FBXSDK_DLL FbxCallocProc FbxGetDefaultCallocHandler()
Get the default global zero'd memory allocation function used internally by the FBX SDK...
static void DeleteIt(Type **pPtr)
Destruction policy implementation.
FBXSDK_DLL void FbxSetReallocHandler(FbxReallocProc pHandler)
Set the global memory re-allocation function used internally by the FBX SDK.
FBXSDK_DLL FbxFreeProc FbxGetDefaultFreeHandler()
Get the default global memory freeing function used internally by the FBX SDK.
bool operator!() const
Logical not operator.
FBXSDK_DLL FbxMallocProc FbxGetDefaultMallocHandler()
Get the default global memory allocation function used internally by the FBX SDK. ...
void *(* FbxReallocProc)(void *, size_t)
Function pointer signature used to replace "calloc".
Scoped pointer for FbxNew allocations, which call FbxDelete() to deallocate.
FBXSDK_DLL void FbxSetMallocHandler(FbxMallocProc pHandler)
Function pointer signature used to replace "free".
void *(* FbxCallocProc)(size_t, size_t)
Function pointer signature used to replace "malloc".
Type & operator*() const
Dereference operator.
Scoped pointer for FbxMalloc allocations, which call FbxFree() to deallocate.
Scoped pointer for FbxObject derived classes, which call Destroy() to deallocate. ...
Type & operator*() const
Dereference operator.
bool operator!() const
Logical not operator.
Deletion policy for pointer template classes that uses the delete operator.
Scoped pointer for FbxNew allocations, which call FbxDelete() to deallocate.
FbxAutoFreePtr(Type *pPtr=0)
Construct from a pointer.
void *(* FbxMallocProc)(size_t)
FBXSDK_DLL FbxCallocProc FbxGetCallocHandler()
Get the global zero'd memory allocation function used internally by the FBX SDK.
Scoped pointer for FbxMalloc allocations, which call FbxFree() to deallocate.
Type * operator->() const
Member access operator.
FbxAutoPtr(Type *pPtr=0)
Construct from a pointer.
FBXSDK_DLL void FbxSetCallocHandler(FbxCallocProc pHandler)
Set the global zero'd memory allocation function used internally by the FBX SDK.
FbxSharedPtr & operator=(const FbxSharedPtr &pSPtr)
Scoped pointer for FbxObject derived classes, which call Destroy() to deallocate. ...
void Swap(FbxAutoPtr &pOther)
Swap with another pointer.
FBXSDK_DLL void FbxSetFreeHandler(FbxFreeProc pHandler)
Set the global memory freeing function used internally by the FBX SDK.
FbxSharedFreePtr(Type *pPtr=0)
Construct from a pointer.
static void DeleteIt(Type **mPtr)
Destruction policy implementation.
Type * Release()
Release the pointer, so that it won't perform deletion in its destruction.