버전
menu_open
link

include/AK/SoundEngine/Common/IAkPluginMemAlloc.h

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright (c) 2006 Audiokinetic Inc. / All Rights Reserved
00004 //
00006 
00009 
00010 #ifndef _IAKPLUGINMEMALLOC_H_
00011 #define _IAKPLUGINMEMALLOC_H_
00012 
00013 #include <AK/SoundEngine/Common/AkTypes.h>
00014 #include <AK/SoundEngine/Common/AkMemoryMgr.h> // For AK_MEMDEBUG
00015 
00016 namespace AK
00017 {
00024     class IAkPluginMemAlloc
00025     {
00026     protected:
00028         virtual ~IAkPluginMemAlloc(){}
00029 
00030     public:
00031         
00036         virtual void * Malloc( 
00037             size_t in_uSize     
00038             ) = 0;
00039 
00043         virtual void Free(
00044             void * in_pMemAddress   
00045             ) = 0;
00046 
00047 #if defined (AK_MEMDEBUG)
00048 
00049 
00050 
00051         virtual void * dMalloc( 
00052             size_t   in_uSize,      
00053             const char*  in_pszFile,
00054             AkUInt32 in_uLine       
00055             ) = 0;
00056 #endif
00057     };
00058 }
00059 
00060 // Memory allocation macros to be used by sound engine plug-ins.
00061 #if defined (AK_MEMDEBUG)
00062 
00063     AkForceInline void * operator new(size_t size,AK::IAkPluginMemAlloc * in_pAllocator,const char* szFile,AkUInt32 ulLine) throw()
00064     {
00065         return in_pAllocator->dMalloc( size, szFile, ulLine );
00066     }
00067 
00068 #ifndef AK_3DS
00069         AkForceInline void operator delete(void *, AK::IAkPluginMemAlloc *, const char*, AkUInt32) throw() {}
00070 #endif
00071     
00072 #endif
00073 
00074     AkForceInline void * operator new(size_t size,AK::IAkPluginMemAlloc * in_pAllocator) throw()
00075     {
00076         return in_pAllocator->Malloc( size );
00077     }
00078     
00079     #ifdef AK_PS3
00080     AkForceInline void * operator new(size_t size, unsigned int align, AK::IAkPluginMemAlloc * in_pAllocator) throw()
00081     {
00082         return in_pAllocator->Malloc( size );
00083     }
00084     #endif
00085 
00086     #ifndef AK_3DS
00087     AkForceInline void operator delete(void *,AK::IAkPluginMemAlloc *) throw() {}
00088     #endif
00089 
00090 #if defined (AK_MEMDEBUG)
00091     #define AK_PLUGIN_NEW(_allocator,_what)             new((_allocator),__FILE__,__LINE__) _what
00092     #define AK_PLUGIN_ALLOC(_allocator,_size)           (_allocator)->dMalloc((_size),__FILE__,__LINE__)
00093 #else
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102     #define AK_PLUGIN_NEW(_allocator,_what)             new(_allocator) _what
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111     #define AK_PLUGIN_ALLOC(_allocator,_size)           (_allocator)->Malloc((_size))
00112 #endif
00113 
00120 template <class T>
00121 AkForceInline void AK_PLUGIN_DELETE( AK::IAkPluginMemAlloc * in_pAllocator, T * in_pObject )      
00122 {
00123     if ( in_pObject )
00124     {
00125         in_pObject->~T();
00126         in_pAllocator->Free( in_pObject );
00127     }
00128 }
00129 
00136 #define AK_PLUGIN_FREE(_allocator,_pvmem)       (_allocator)->Free((_pvmem))
00137 
00138 #endif // _IAKPLUGINMEMALLOC_H_

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요