Commit 37a36bbf authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

combase: Move FreePropVariantArray() and PropVariantClear().

parent eb316eda
......@@ -6,6 +6,7 @@ DELAYIMPORTS = oleaut32
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
combase.c \
errorinfo.c \
malloc.c \
roapi.c \
......
/*
* Copyright 2005 Juan Lang
* Copyright 2005-2006 Robert Shearman (for CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#define NONAMELESSUNION
#include "oleauto.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
/***********************************************************************
* FreePropVariantArray (combase.@)
*/
HRESULT WINAPI FreePropVariantArray(ULONG count, PROPVARIANT *rgvars)
{
ULONG i;
TRACE("%u, %p.\n", count, rgvars);
if (!rgvars)
return E_INVALIDARG;
for (i = 0; i < count; ++i)
PropVariantClear(&rgvars[i]);
return S_OK;
}
static HRESULT propvar_validatetype(VARTYPE vt)
{
switch (vt)
{
case VT_EMPTY:
case VT_NULL:
case VT_I1:
case VT_I2:
case VT_I4:
case VT_I8:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_BSTR:
case VT_ERROR:
case VT_BOOL:
case VT_DECIMAL:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_UI8:
case VT_INT:
case VT_UINT:
case VT_LPSTR:
case VT_LPWSTR:
case VT_FILETIME:
case VT_BLOB:
case VT_DISPATCH:
case VT_UNKNOWN:
case VT_STREAM:
case VT_STORAGE:
case VT_STREAMED_OBJECT:
case VT_STORED_OBJECT:
case VT_BLOB_OBJECT:
case VT_CF:
case VT_CLSID:
case VT_I1|VT_VECTOR:
case VT_I2|VT_VECTOR:
case VT_I4|VT_VECTOR:
case VT_I8|VT_VECTOR:
case VT_R4|VT_VECTOR:
case VT_R8|VT_VECTOR:
case VT_CY|VT_VECTOR:
case VT_DATE|VT_VECTOR:
case VT_BSTR|VT_VECTOR:
case VT_ERROR|VT_VECTOR:
case VT_BOOL|VT_VECTOR:
case VT_VARIANT|VT_VECTOR:
case VT_UI1|VT_VECTOR:
case VT_UI2|VT_VECTOR:
case VT_UI4|VT_VECTOR:
case VT_UI8|VT_VECTOR:
case VT_LPSTR|VT_VECTOR:
case VT_LPWSTR|VT_VECTOR:
case VT_FILETIME|VT_VECTOR:
case VT_CF|VT_VECTOR:
case VT_CLSID|VT_VECTOR:
case VT_ARRAY|VT_I1:
case VT_ARRAY|VT_UI1:
case VT_ARRAY|VT_I2:
case VT_ARRAY|VT_UI2:
case VT_ARRAY|VT_I4:
case VT_ARRAY|VT_UI4:
case VT_ARRAY|VT_INT:
case VT_ARRAY|VT_UINT:
case VT_ARRAY|VT_R4:
case VT_ARRAY|VT_R8:
case VT_ARRAY|VT_CY:
case VT_ARRAY|VT_DATE:
case VT_ARRAY|VT_BSTR:
case VT_ARRAY|VT_BOOL:
case VT_ARRAY|VT_DECIMAL:
case VT_ARRAY|VT_DISPATCH:
case VT_ARRAY|VT_UNKNOWN:
case VT_ARRAY|VT_ERROR:
case VT_ARRAY|VT_VARIANT:
return S_OK;
}
WARN("Bad type %d\n", vt);
return STG_E_INVALIDPARAMETER;
}
static void propvar_free_cf_array(ULONG count, CLIPDATA *data)
{
ULONG i;
for (i = 0; i < count; ++i)
CoTaskMemFree(data[i].pClipData);
}
/***********************************************************************
* PropVariantClear (combase.@)
*/
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
{
HRESULT hr;
TRACE("%p.\n", pvar);
if (!pvar)
return S_OK;
hr = propvar_validatetype(pvar->vt);
if (FAILED(hr))
{
memset(pvar, 0, sizeof(*pvar));
return hr;
}
switch (pvar->vt)
{
case VT_EMPTY:
case VT_NULL:
case VT_I1:
case VT_I2:
case VT_I4:
case VT_I8:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_ERROR:
case VT_BOOL:
case VT_DECIMAL:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_UI8:
case VT_INT:
case VT_UINT:
case VT_FILETIME:
break;
case VT_DISPATCH:
case VT_UNKNOWN:
case VT_STREAM:
case VT_STREAMED_OBJECT:
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pvar->u.pStream)
IStream_Release(pvar->u.pStream);
break;
case VT_CLSID:
case VT_LPSTR:
case VT_LPWSTR:
/* pick an arbitrary typed pointer - we don't care about the type
* as we are just freeing it */
CoTaskMemFree(pvar->u.puuid);
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
CoTaskMemFree(pvar->u.blob.pBlobData);
break;
case VT_BSTR:
SysFreeString(pvar->u.bstrVal);
break;
case VT_CF:
if (pvar->u.pclipdata)
{
propvar_free_cf_array(1, pvar->u.pclipdata);
CoTaskMemFree(pvar->u.pclipdata);
}
break;
default:
if (pvar->vt & VT_VECTOR)
{
ULONG i;
switch (pvar->vt & ~VT_VECTOR)
{
case VT_VARIANT:
FreePropVariantArray(pvar->u.capropvar.cElems, pvar->u.capropvar.pElems);
break;
case VT_CF:
propvar_free_cf_array(pvar->u.caclipdata.cElems, pvar->u.caclipdata.pElems);
break;
case VT_BSTR:
for (i = 0; i < pvar->u.cabstr.cElems; i++)
SysFreeString(pvar->u.cabstr.pElems[i]);
break;
case VT_LPSTR:
for (i = 0; i < pvar->u.calpstr.cElems; i++)
CoTaskMemFree(pvar->u.calpstr.pElems[i]);
break;
case VT_LPWSTR:
for (i = 0; i < pvar->u.calpwstr.cElems; i++)
CoTaskMemFree(pvar->u.calpwstr.pElems[i]);
break;
}
if (pvar->vt & ~VT_VECTOR)
{
/* pick an arbitrary VT_VECTOR structure - they all have the same
* memory layout */
CoTaskMemFree(pvar->u.capropvar.pElems);
}
}
else if (pvar->vt & VT_ARRAY)
hr = SafeArrayDestroy(pvar->u.parray);
else
{
WARN("Invalid/unsupported type %d\n", pvar->vt);
hr = STG_E_INVALIDPARAMETER;
}
}
memset(pvar, 0, sizeof(*pvar));
return hr;
}
......@@ -177,7 +177,7 @@
@ stdcall DllGetActivationFactory(ptr ptr)
@ stdcall -private DllGetClassObject(ptr ptr ptr) ole32.DllGetClassObject
@ stub EnableHookObject
@ stdcall FreePropVariantArray(long ptr) ole32.FreePropVariantArray
@ stdcall FreePropVariantArray(long ptr)
@ stub FreePropVariantArrayWorker
@ stub GetCatalogHelper
@ stdcall GetErrorInfo(long ptr) ole32.GetErrorInfo
......@@ -279,7 +279,7 @@
@ stub NdrOleDllGetClassObject
@ stub NdrpFindInterface
@ stdcall ProgIDFromCLSID(ptr ptr) ole32.ProgIDFromCLSID
@ stdcall PropVariantClear(ptr) ole32.PropVariantClear
@ stdcall PropVariantClear(ptr)
@ stdcall PropVariantCopy(ptr ptr) ole32.PropVariantCopy
@ stub ReleaseFuncDescs
@ stdcall RoActivateInstance(ptr ptr)
......
......@@ -2710,20 +2710,6 @@ HRESULT WINAPI OleNoteObjectVisible(LPUNKNOWN pUnknown, BOOL bVisible)
return CoLockObjectExternal(pUnknown, bVisible, TRUE);
}
/***********************************************************************
* OLE_FreeClipDataArray [internal]
*
* NOTES:
* frees the data associated with an array of CLIPDATAs
*/
static void OLE_FreeClipDataArray(ULONG count, CLIPDATA * pClipDataArray)
{
ULONG i;
for (i = 0; i < count; i++)
CoTaskMemFree(pClipDataArray[i].pClipData);
}
/***********************************************************************
* PropSysAllocString [OLE32.@]
* NOTES
......@@ -2831,124 +2817,6 @@ static inline HRESULT PROPVARIANT_ValidateType(VARTYPE vt)
}
/***********************************************************************
* PropVariantClear [OLE32.@]
*/
HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
{
HRESULT hr;
TRACE("(%p)\n", pvar);
if (!pvar)
return S_OK;
hr = PROPVARIANT_ValidateType(pvar->vt);
if (FAILED(hr))
{
memset(pvar, 0, sizeof(*pvar));
return hr;
}
switch(pvar->vt)
{
case VT_EMPTY:
case VT_NULL:
case VT_I1:
case VT_I2:
case VT_I4:
case VT_I8:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_ERROR:
case VT_BOOL:
case VT_DECIMAL:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_UI8:
case VT_INT:
case VT_UINT:
case VT_FILETIME:
break;
case VT_DISPATCH:
case VT_UNKNOWN:
case VT_STREAM:
case VT_STREAMED_OBJECT:
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pvar->u.pStream)
IStream_Release(pvar->u.pStream);
break;
case VT_CLSID:
case VT_LPSTR:
case VT_LPWSTR:
/* pick an arbitrary typed pointer - we don't care about the type
* as we are just freeing it */
CoTaskMemFree(pvar->u.puuid);
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
CoTaskMemFree(pvar->u.blob.pBlobData);
break;
case VT_BSTR:
PropSysFreeString(pvar->u.bstrVal);
break;
case VT_CF:
if (pvar->u.pclipdata)
{
OLE_FreeClipDataArray(1, pvar->u.pclipdata);
CoTaskMemFree(pvar->u.pclipdata);
}
break;
default:
if (pvar->vt & VT_VECTOR)
{
ULONG i;
switch (pvar->vt & ~VT_VECTOR)
{
case VT_VARIANT:
FreePropVariantArray(pvar->u.capropvar.cElems, pvar->u.capropvar.pElems);
break;
case VT_CF:
OLE_FreeClipDataArray(pvar->u.caclipdata.cElems, pvar->u.caclipdata.pElems);
break;
case VT_BSTR:
for (i = 0; i < pvar->u.cabstr.cElems; i++)
PropSysFreeString(pvar->u.cabstr.pElems[i]);
break;
case VT_LPSTR:
for (i = 0; i < pvar->u.calpstr.cElems; i++)
CoTaskMemFree(pvar->u.calpstr.pElems[i]);
break;
case VT_LPWSTR:
for (i = 0; i < pvar->u.calpwstr.cElems; i++)
CoTaskMemFree(pvar->u.calpwstr.pElems[i]);
break;
}
if (pvar->vt & ~VT_VECTOR)
{
/* pick an arbitrary VT_VECTOR structure - they all have the same
* memory layout */
CoTaskMemFree(pvar->u.capropvar.pElems);
}
}
else if (pvar->vt & VT_ARRAY)
hr = SafeArrayDestroy(pvar->u.parray);
else
{
WARN("Invalid/unsupported type %d\n", pvar->vt);
hr = STG_E_INVALIDPARAMETER;
}
}
memset(pvar, 0, sizeof(*pvar));
return hr;
}
/***********************************************************************
* PropVariantCopy [OLE32.@]
*/
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
......@@ -3129,25 +2997,6 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
return S_OK;
}
/***********************************************************************
* FreePropVariantArray [OLE32.@]
*/
HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */
PROPVARIANT *rgvars) /* [in/out] */
{
ULONG i;
TRACE("(%u, %p)\n", cVariants, rgvars);
if (!rgvars)
return E_INVALIDARG;
for(i = 0; i < cVariants; i++)
PropVariantClear(&rgvars[i]);
return S_OK;
}
/******************************************************************************
* DllDebugObjectRPCHook (OLE32.@)
* turns on and off internal debugging, pointer is only used on macintosh
......
......@@ -114,7 +114,7 @@
@ stdcall DoDragDrop(ptr ptr long ptr)
@ stub EnableHookObject
@ stdcall FmtIdToPropStgName(ptr wstr)
@ stdcall FreePropVariantArray(long ptr)
@ stdcall FreePropVariantArray(long ptr) combase.FreePropVariantArray
@ stdcall GetClassFile(wstr ptr)
@ stdcall GetConvertStg(ptr)
@ stub GetDocumentBitStg
......@@ -241,7 +241,7 @@
@ stdcall PropStgNameToFmtId(wstr ptr)
@ stdcall PropSysAllocString(wstr)
@ stdcall PropSysFreeString(wstr)
@ stdcall PropVariantClear(ptr)
@ stdcall PropVariantClear(ptr) combase.PropVariantClear
@ stdcall PropVariantCopy(ptr ptr)
@ stdcall ReadClassStg(ptr ptr)
@ stdcall ReadClassStm(ptr ptr)
......
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