Commit 49b97bad authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

combase: Use nameless unions.

parent d1764a45
......@@ -2,7 +2,6 @@ MODULE = combase.dll
IMPORTLIB = combase
IMPORTS = advapi32 ole32 user32 gdi32 uuid rpcrt4
DELAYIMPORTS = oleaut32
EXTRADEFS = -DWINE_NO_NAMELESS_EXTENSION
EXTRADLLFLAGS = -mno-cygwin
......
......@@ -585,28 +585,28 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
case VT_STREAMED_OBJECT:
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pvar->u.pStream)
IStream_Release(pvar->u.pStream);
if (pvar->pStream)
IStream_Release(pvar->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);
CoTaskMemFree(pvar->puuid);
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
CoTaskMemFree(pvar->u.blob.pBlobData);
CoTaskMemFree(pvar->blob.pBlobData);
break;
case VT_BSTR:
SysFreeString(pvar->u.bstrVal);
SysFreeString(pvar->bstrVal);
break;
case VT_CF:
if (pvar->u.pclipdata)
if (pvar->pclipdata)
{
propvar_free_cf_array(1, pvar->u.pclipdata);
CoTaskMemFree(pvar->u.pclipdata);
propvar_free_cf_array(1, pvar->pclipdata);
CoTaskMemFree(pvar->pclipdata);
}
break;
default:
......@@ -617,33 +617,33 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
switch (pvar->vt & ~VT_VECTOR)
{
case VT_VARIANT:
FreePropVariantArray(pvar->u.capropvar.cElems, pvar->u.capropvar.pElems);
FreePropVariantArray(pvar->capropvar.cElems, pvar->capropvar.pElems);
break;
case VT_CF:
propvar_free_cf_array(pvar->u.caclipdata.cElems, pvar->u.caclipdata.pElems);
propvar_free_cf_array(pvar->caclipdata.cElems, pvar->caclipdata.pElems);
break;
case VT_BSTR:
for (i = 0; i < pvar->u.cabstr.cElems; i++)
SysFreeString(pvar->u.cabstr.pElems[i]);
for (i = 0; i < pvar->cabstr.cElems; i++)
SysFreeString(pvar->cabstr.pElems[i]);
break;
case VT_LPSTR:
for (i = 0; i < pvar->u.calpstr.cElems; i++)
CoTaskMemFree(pvar->u.calpstr.pElems[i]);
for (i = 0; i < pvar->calpstr.cElems; i++)
CoTaskMemFree(pvar->calpstr.pElems[i]);
break;
case VT_LPWSTR:
for (i = 0; i < pvar->u.calpwstr.cElems; i++)
CoTaskMemFree(pvar->u.calpwstr.pElems[i]);
for (i = 0; i < pvar->calpwstr.cElems; i++)
CoTaskMemFree(pvar->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);
CoTaskMemFree(pvar->capropvar.pElems);
}
}
else if (pvar->vt & VT_ARRAY)
hr = SafeArrayDestroy(pvar->u.parray);
hr = SafeArrayDestroy(pvar->parray);
else
{
WARN("Invalid/unsupported type %d\n", pvar->vt);
......@@ -701,50 +701,50 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc
case VT_STREAMED_OBJECT:
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pvarDest->u.pStream)
IStream_AddRef(pvarDest->u.pStream);
if (pvarDest->pStream)
IStream_AddRef(pvarDest->pStream);
break;
case VT_CLSID:
pvarDest->u.puuid = CoTaskMemAlloc(sizeof(CLSID));
*pvarDest->u.puuid = *pvarSrc->u.puuid;
pvarDest->puuid = CoTaskMemAlloc(sizeof(CLSID));
*pvarDest->puuid = *pvarSrc->puuid;
break;
case VT_LPSTR:
if (pvarSrc->u.pszVal)
if (pvarSrc->pszVal)
{
len = strlen(pvarSrc->u.pszVal);
pvarDest->u.pszVal = CoTaskMemAlloc((len+1)*sizeof(CHAR));
CopyMemory(pvarDest->u.pszVal, pvarSrc->u.pszVal, (len+1)*sizeof(CHAR));
len = strlen(pvarSrc->pszVal);
pvarDest->pszVal = CoTaskMemAlloc((len+1)*sizeof(CHAR));
CopyMemory(pvarDest->pszVal, pvarSrc->pszVal, (len+1)*sizeof(CHAR));
}
break;
case VT_LPWSTR:
if (pvarSrc->u.pwszVal)
if (pvarSrc->pwszVal)
{
len = lstrlenW(pvarSrc->u.pwszVal);
pvarDest->u.pwszVal = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
CopyMemory(pvarDest->u.pwszVal, pvarSrc->u.pwszVal, (len+1)*sizeof(WCHAR));
len = lstrlenW(pvarSrc->pwszVal);
pvarDest->pwszVal = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
CopyMemory(pvarDest->pwszVal, pvarSrc->pwszVal, (len+1)*sizeof(WCHAR));
}
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
if (pvarSrc->u.blob.pBlobData)
if (pvarSrc->blob.pBlobData)
{
len = pvarSrc->u.blob.cbSize;
pvarDest->u.blob.pBlobData = CoTaskMemAlloc(len);
CopyMemory(pvarDest->u.blob.pBlobData, pvarSrc->u.blob.pBlobData, len);
len = pvarSrc->blob.cbSize;
pvarDest->blob.pBlobData = CoTaskMemAlloc(len);
CopyMemory(pvarDest->blob.pBlobData, pvarSrc->blob.pBlobData, len);
}
break;
case VT_BSTR:
pvarDest->u.bstrVal = SysAllocString(pvarSrc->u.bstrVal);
pvarDest->bstrVal = SysAllocString(pvarSrc->bstrVal);
break;
case VT_CF:
if (pvarSrc->u.pclipdata)
if (pvarSrc->pclipdata)
{
len = pvarSrc->u.pclipdata->cbSize - sizeof(pvarSrc->u.pclipdata->ulClipFmt);
pvarDest->u.pclipdata = CoTaskMemAlloc(sizeof (CLIPDATA));
pvarDest->u.pclipdata->cbSize = pvarSrc->u.pclipdata->cbSize;
pvarDest->u.pclipdata->ulClipFmt = pvarSrc->u.pclipdata->ulClipFmt;
pvarDest->u.pclipdata->pClipData = CoTaskMemAlloc(len);
CopyMemory(pvarDest->u.pclipdata->pClipData, pvarSrc->u.pclipdata->pClipData, len);
len = pvarSrc->pclipdata->cbSize - sizeof(pvarSrc->pclipdata->ulClipFmt);
pvarDest->pclipdata = CoTaskMemAlloc(sizeof (CLIPDATA));
pvarDest->pclipdata->cbSize = pvarSrc->pclipdata->cbSize;
pvarDest->pclipdata->ulClipFmt = pvarSrc->pclipdata->ulClipFmt;
pvarDest->pclipdata->pClipData = CoTaskMemAlloc(len);
CopyMemory(pvarDest->pclipdata->pClipData, pvarSrc->pclipdata->pClipData, len);
}
break;
default:
......@@ -755,38 +755,38 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc
switch (pvarSrc->vt & ~VT_VECTOR)
{
case VT_I1: elemSize = sizeof(pvarSrc->u.cVal); break;
case VT_UI1: elemSize = sizeof(pvarSrc->u.bVal); break;
case VT_I2: elemSize = sizeof(pvarSrc->u.iVal); break;
case VT_UI2: elemSize = sizeof(pvarSrc->u.uiVal); break;
case VT_BOOL: elemSize = sizeof(pvarSrc->u.boolVal); break;
case VT_I4: elemSize = sizeof(pvarSrc->u.lVal); break;
case VT_UI4: elemSize = sizeof(pvarSrc->u.ulVal); break;
case VT_R4: elemSize = sizeof(pvarSrc->u.fltVal); break;
case VT_R8: elemSize = sizeof(pvarSrc->u.dblVal); break;
case VT_ERROR: elemSize = sizeof(pvarSrc->u.scode); break;
case VT_I8: elemSize = sizeof(pvarSrc->u.hVal); break;
case VT_UI8: elemSize = sizeof(pvarSrc->u.uhVal); break;
case VT_CY: elemSize = sizeof(pvarSrc->u.cyVal); break;
case VT_DATE: elemSize = sizeof(pvarSrc->u.date); break;
case VT_FILETIME: elemSize = sizeof(pvarSrc->u.filetime); break;
case VT_CLSID: elemSize = sizeof(*pvarSrc->u.puuid); break;
case VT_CF: elemSize = sizeof(*pvarSrc->u.pclipdata); break;
case VT_BSTR: elemSize = sizeof(pvarSrc->u.bstrVal); break;
case VT_LPSTR: elemSize = sizeof(pvarSrc->u.pszVal); break;
case VT_LPWSTR: elemSize = sizeof(pvarSrc->u.pwszVal); break;
case VT_VARIANT: elemSize = sizeof(*pvarSrc->u.pvarVal); break;
case VT_I1: elemSize = sizeof(pvarSrc->cVal); break;
case VT_UI1: elemSize = sizeof(pvarSrc->bVal); break;
case VT_I2: elemSize = sizeof(pvarSrc->iVal); break;
case VT_UI2: elemSize = sizeof(pvarSrc->uiVal); break;
case VT_BOOL: elemSize = sizeof(pvarSrc->boolVal); break;
case VT_I4: elemSize = sizeof(pvarSrc->lVal); break;
case VT_UI4: elemSize = sizeof(pvarSrc->ulVal); break;
case VT_R4: elemSize = sizeof(pvarSrc->fltVal); break;
case VT_R8: elemSize = sizeof(pvarSrc->dblVal); break;
case VT_ERROR: elemSize = sizeof(pvarSrc->scode); break;
case VT_I8: elemSize = sizeof(pvarSrc->hVal); break;
case VT_UI8: elemSize = sizeof(pvarSrc->uhVal); break;
case VT_CY: elemSize = sizeof(pvarSrc->cyVal); break;
case VT_DATE: elemSize = sizeof(pvarSrc->date); break;
case VT_FILETIME: elemSize = sizeof(pvarSrc->filetime); break;
case VT_CLSID: elemSize = sizeof(*pvarSrc->puuid); break;
case VT_CF: elemSize = sizeof(*pvarSrc->pclipdata); break;
case VT_BSTR: elemSize = sizeof(pvarSrc->bstrVal); break;
case VT_LPSTR: elemSize = sizeof(pvarSrc->pszVal); break;
case VT_LPWSTR: elemSize = sizeof(pvarSrc->pwszVal); break;
case VT_VARIANT: elemSize = sizeof(*pvarSrc->pvarVal); break;
default:
FIXME("Invalid element type: %ul\n", pvarSrc->vt & ~VT_VECTOR);
return E_INVALIDARG;
}
len = pvarSrc->u.capropvar.cElems;
pvarDest->u.capropvar.pElems = len ? CoTaskMemAlloc(len * elemSize) : NULL;
len = pvarSrc->capropvar.cElems;
pvarDest->capropvar.pElems = len ? CoTaskMemAlloc(len * elemSize) : NULL;
if (pvarSrc->vt == (VT_VECTOR | VT_VARIANT))
{
for (i = 0; i < len; i++)
PropVariantCopy(&pvarDest->u.capropvar.pElems[i], &pvarSrc->u.capropvar.pElems[i]);
PropVariantCopy(&pvarDest->capropvar.pElems[i], &pvarSrc->capropvar.pElems[i]);
}
else if (pvarSrc->vt == (VT_VECTOR | VT_CF))
{
......@@ -795,17 +795,17 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc
else if (pvarSrc->vt == (VT_VECTOR | VT_BSTR))
{
for (i = 0; i < len; i++)
pvarDest->u.cabstr.pElems[i] = SysAllocString(pvarSrc->u.cabstr.pElems[i]);
pvarDest->cabstr.pElems[i] = SysAllocString(pvarSrc->cabstr.pElems[i]);
}
else if (pvarSrc->vt == (VT_VECTOR | VT_LPSTR))
{
size_t strLen;
for (i = 0; i < len; i++)
{
strLen = lstrlenA(pvarSrc->u.calpstr.pElems[i]) + 1;
pvarDest->u.calpstr.pElems[i] = CoTaskMemAlloc(strLen);
memcpy(pvarDest->u.calpstr.pElems[i],
pvarSrc->u.calpstr.pElems[i], strLen);
strLen = lstrlenA(pvarSrc->calpstr.pElems[i]) + 1;
pvarDest->calpstr.pElems[i] = CoTaskMemAlloc(strLen);
memcpy(pvarDest->calpstr.pElems[i],
pvarSrc->calpstr.pElems[i], strLen);
}
}
else if (pvarSrc->vt == (VT_VECTOR | VT_LPWSTR))
......@@ -813,20 +813,20 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc
size_t strLen;
for (i = 0; i < len; i++)
{
strLen = (lstrlenW(pvarSrc->u.calpwstr.pElems[i]) + 1) *
strLen = (lstrlenW(pvarSrc->calpwstr.pElems[i]) + 1) *
sizeof(WCHAR);
pvarDest->u.calpstr.pElems[i] = CoTaskMemAlloc(strLen);
memcpy(pvarDest->u.calpstr.pElems[i],
pvarSrc->u.calpstr.pElems[i], strLen);
pvarDest->calpstr.pElems[i] = CoTaskMemAlloc(strLen);
memcpy(pvarDest->calpstr.pElems[i],
pvarSrc->calpstr.pElems[i], strLen);
}
}
else
CopyMemory(pvarDest->u.capropvar.pElems, pvarSrc->u.capropvar.pElems, len * elemSize);
CopyMemory(pvarDest->capropvar.pElems, pvarSrc->capropvar.pElems, len * elemSize);
}
else if (pvarSrc->vt & VT_ARRAY)
{
pvarDest->u.uhVal.QuadPart = 0;
return SafeArrayCopy(pvarSrc->u.parray, &pvarDest->u.parray);
pvarDest->uhVal.QuadPart = 0;
return SafeArrayCopy(pvarSrc->parray, &pvarDest->parray);
}
else
WARN("Invalid/unsupported type %d\n", pvarSrc->vt);
......
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