Using IMalloc::Free instead of delete for Release.

This commit is contained in:
Adam Yang 2017-10-20 14:39:54 -07:00
Родитель 40369a5884
Коммит 2fea86ac2b
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -93,6 +93,11 @@ inline T *CreateOnMalloc(IMalloc * pMalloc, Args&&... args) {
return (T *)P; \
}
template<typename T>
void DxcCallDestructor(T *obj) {
obj->~T();
}
// The "TM" version keep an IMalloc field that, if not null, indicate
// ownership of 'this' and of any allocations used during release.
#define DXC_MICROCOM_TM_REF_FIELDS() \
@ -104,7 +109,8 @@ inline T *CreateOnMalloc(IMalloc * pMalloc, Args&&... args) {
ULONG result = InterlockedDecrement(&m_dwRef); \
if (result == 0) { \
CComPtr<IMalloc> pTmp(m_pMalloc); \
DxcThreadMalloc M(pTmp); delete this; \
DxcCallDestructor(this); \
pTmp->Free(this); \
} \
return result; \
}