Nikolay Sivov : oleaut32: Use CoTaskMem* functions for safearrays.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jan 6 15:05:17 CST 2015
Module: wine
Branch: master
Commit: adc091b8dad2a02d81fa50b488396b614f169632
URL: http://source.winehq.org/git/wine.git/?a=commit;h=adc091b8dad2a02d81fa50b488396b614f169632
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Jan 6 12:45:16 2015 +0300
oleaut32: Use CoTaskMem* functions for safearrays.
---
dlls/oleaut32/safearray.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/dlls/oleaut32/safearray.c b/dlls/oleaut32/safearray.c
index 99ffe27..01dbfc3 100644
--- a/dlls/oleaut32/safearray.c
+++ b/dlls/oleaut32/safearray.c
@@ -95,18 +95,18 @@ static const USHORT ignored_copy_features =
FADF_CREATEVECTOR;
/* Allocate memory */
-static inline LPVOID SAFEARRAY_Malloc(ULONG ulSize)
+static inline void* SAFEARRAY_Malloc(ULONG size)
{
- /* FIXME: Memory should be allocated and freed using a per-thread IMalloc
- * instance returned from CoGetMalloc().
- */
- return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulSize);
+ void *ret = CoTaskMemAlloc(size);
+ if (ret)
+ memset(ret, 0, size);
+ return ret;
}
/* Free memory */
-static inline BOOL SAFEARRAY_Free(LPVOID lpData)
+static inline void SAFEARRAY_Free(void *ptr)
{
- return HeapFree(GetProcessHeap(), 0, lpData);
+ CoTaskMemFree(ptr);
}
/* Get the size of a supported VT type (0 means unsupported) */
@@ -772,8 +772,7 @@ HRESULT WINAPI SafeArrayDestroyDescriptor(SAFEARRAY *psa)
!(psa->fFeatures & FADF_DATADELETED))
SAFEARRAY_DestroyData(psa, 0); /* Data not previously deleted */
- if (!SAFEARRAY_Free(lpv))
- return E_UNEXPECTED;
+ SAFEARRAY_Free(lpv);
}
return S_OK;
}
@@ -1283,8 +1282,7 @@ HRESULT WINAPI SafeArrayDestroyData(SAFEARRAY *psa)
/* If this is not a vector, free the data memory block */
if (!(psa->fFeatures & FADF_CREATEVECTOR))
{
- if (!SAFEARRAY_Free(psa->pvData))
- return E_UNEXPECTED;
+ SAFEARRAY_Free(psa->pvData);
psa->pvData = NULL;
}
else
More information about the wine-cvs
mailing list