00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00020 #ifndef _FBXSDK_CORE_ARCH_ALLOC_H_
00021 #define _FBXSDK_CORE_ARCH_ALLOC_H_
00022
00023 #include <fbxsdk/fbxsdk_def.h>
00024
00025 #if defined(_DEBUG) && defined(FBXSDK_ENV_WIN)
00026 #include <crtdbg.h>
00027 #endif
00028
00029 #if defined(FBXSDK_ENV_MAC)
00030 #include <malloc/malloc.h>
00031 #else
00032 #include <malloc.h>
00033 #endif
00034
00035 #include <fbxsdk/fbxsdk_nsbegin.h>
00036
00037 #if defined(FBXSDK_ARCH_32)
00038 #define FBXSDK_MEMORY_ALIGNMENT 4
00039 #elif defined(FBXSDK_ARCH_64)
00040 #define FBXSDK_MEMORY_ALIGNMENT 8
00041 #endif
00042
00043 #ifndef _msize
00044 #if defined(FBXSDK_ENV_MAC)
00045 #define _msize ((size_t(*)(void*))malloc_size)
00046 #elif defined(FBXSDK_ENV_LINUX)
00047 #define _msize ((size_t(*)(void*))malloc_usable_size)
00048 #endif
00049 #endif
00050
00051 #if defined(_DEBUG) && defined(FBXSDK_ENV_WIN)
00052 typedef void* (*FbxMallocProc)(size_t, int, const char*, int);
00053 typedef void* (*FbxCallocProc)(size_t, size_t, int, const char*, int);
00054 typedef void* (*FbxReallocProc)(void*, size_t, int, const char*, int);
00055 typedef void (*FbxFreeProc)(void*, int);
00056 typedef size_t (*FbxMSizeProc)(void*, int);
00057 #else
00058 typedef void* (*FbxMallocProc)(size_t);
00059 typedef void* (*FbxCallocProc)(size_t, size_t);
00060 typedef void* (*FbxReallocProc)(void*, size_t);
00061 typedef void (*FbxFreeProc)(void*);
00062 typedef size_t (*FbxMSizeProc)(void*);
00063 #endif
00064
00068 FBXSDK_DLL void FbxSetMallocHandler(FbxMallocProc pHandler);
00069
00073 FBXSDK_DLL void FbxSetCallocHandler(FbxCallocProc pHandler);
00074
00078 FBXSDK_DLL void FbxSetReallocHandler(FbxReallocProc pHandler);
00079
00083 FBXSDK_DLL void FbxSetFreeHandler(FbxFreeProc pHandler);
00084
00088 FBXSDK_DLL void FbxSetMSizeHandler(FbxMSizeProc pHandler);
00089
00090
00091 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00092 FBXSDK_DLL void* FbxMalloc(size_t pSize);
00093 FBXSDK_DLL void* FbxCalloc(size_t pCount, size_t pSize);
00094 FBXSDK_DLL void* FbxRealloc(void* pData, size_t pSize);
00095 FBXSDK_DLL void FbxFree(void* pData);
00096 FBXSDK_DLL size_t FbxMSize(void* pData);
00097 FBXSDK_DLL void* FbxMallocAligned(size_t pSize);
00098 FBXSDK_DLL void* FbxCallocAligned(size_t pCount, size_t pSize);
00099 FBXSDK_DLL void* FbxReallocAligned(void* pAlignedPtr, size_t pSize);
00100 FBXSDK_DLL void FbxFreeAligned(void* pAlignedPtr);
00101 FBXSDK_DLL char* FbxStrDup(const char* pString);
00102 FBXSDK_DLL wchar_t* FbxStrDupWC(const wchar_t* pString);
00103
00104 #if defined(_DEBUG) && defined(FBXSDK_ENV_WIN)
00105 FBXSDK_DLL void* FbxMallocDebug(size_t pSize, int pBlock, const char* pFile, int pLine);
00106 FBXSDK_DLL void* FbxCallocDebug(size_t pCount, size_t pSize, int pBlock, const char* pFile, int pLine);
00107 FBXSDK_DLL void* FbxReallocDebug(void* pData, size_t pSize, int pBlock, const char* pFile, int pLine);
00108 FBXSDK_DLL void FbxFreeDebug(void* pData, int pBlock);
00109 FBXSDK_DLL size_t FbxMSizeDebug(void* pData, int pBlock);
00110 FBXSDK_DLL char* FbxStrDupDebug(const char* pString, int pBlock, const char* pFile, int pLine);
00111 FBXSDK_DLL wchar_t* FbxStrDupWCDebug(const wchar_t* pString, int pBlock, const char* pFile, int pLine);
00112
00113 #define FbxMalloc(s) FbxMallocDebug(s, _NORMAL_BLOCK, __FILE__, __LINE__)
00114 #define FbxCalloc(c, s) FbxCallocDebug(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
00115 #define FbxRealloc(p, s) FbxReallocDebug(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
00116 #define FbxFree(p) FbxFreeDebug(p, _NORMAL_BLOCK)
00117 #define FbxMSize(p) FbxMSizeDebug(p, _NORMAL_BLOCK)
00118 #define FbxStrDup(s) FbxStrDupDebug(s, _NORMAL_BLOCK, __FILE__, __LINE__)
00119 #define FbxStrDupWC(s) FbxStrDupWCDebug(s, _NORMAL_BLOCK, __FILE__, __LINE__)
00120 #endif
00121 #endif
00122
00123 #include <fbxsdk/fbxsdk_nsend.h>
00124
00125 #endif