Commit adc091b8 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32: Use CoTaskMem* functions for safearrays.

parent 35a91741
...@@ -95,18 +95,18 @@ static const USHORT ignored_copy_features = ...@@ -95,18 +95,18 @@ static const USHORT ignored_copy_features =
FADF_CREATEVECTOR; FADF_CREATEVECTOR;
/* Allocate memory */ /* 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 void *ret = CoTaskMemAlloc(size);
* instance returned from CoGetMalloc(). if (ret)
*/ memset(ret, 0, size);
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulSize); return ret;
} }
/* Free memory */ /* 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) */ /* Get the size of a supported VT type (0 means unsupported) */
...@@ -772,8 +772,7 @@ HRESULT WINAPI SafeArrayDestroyDescriptor(SAFEARRAY *psa) ...@@ -772,8 +772,7 @@ HRESULT WINAPI SafeArrayDestroyDescriptor(SAFEARRAY *psa)
!(psa->fFeatures & FADF_DATADELETED)) !(psa->fFeatures & FADF_DATADELETED))
SAFEARRAY_DestroyData(psa, 0); /* Data not previously deleted */ SAFEARRAY_DestroyData(psa, 0); /* Data not previously deleted */
if (!SAFEARRAY_Free(lpv)) SAFEARRAY_Free(lpv);
return E_UNEXPECTED;
} }
return S_OK; return S_OK;
} }
...@@ -1283,8 +1282,7 @@ HRESULT WINAPI SafeArrayDestroyData(SAFEARRAY *psa) ...@@ -1283,8 +1282,7 @@ HRESULT WINAPI SafeArrayDestroyData(SAFEARRAY *psa)
/* If this is not a vector, free the data memory block */ /* If this is not a vector, free the data memory block */
if (!(psa->fFeatures & FADF_CREATEVECTOR)) if (!(psa->fFeatures & FADF_CREATEVECTOR))
{ {
if (!SAFEARRAY_Free(psa->pvData)) SAFEARRAY_Free(psa->pvData);
return E_UNEXPECTED;
psa->pvData = NULL; psa->pvData = NULL;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment