[PATCH 5/6] propsys: Partially implement property stringification
Nikolay Sivov
bunglehead at gmail.com
Tue Jul 14 11:55:27 CDT 2015
On 14.07.2015 18:07, Jonas Kümmerlin wrote:
Hi, Jonas, and welcome.
I don't know much about AppUserModelID, but still some comments on your
patches:
> + case VT_LPSTR:
> + *pcch = MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, NULL, 0);
> + break;
You sure it's meant to be WCHAR even for VT_LPSTR type? This looks wrong
to me.
> + case VT_LPSTR:
> + {
> + UINT len = MultiByteToWideChar(CP_ACP, 0, propvar->u.pszVal, -1, NULL, 0);
> + if (len == 0)
> + {
> + hr = E_FAIL;
> + break;
> + }
> +
> + if (len < cch)
> + {
> + MultiByteToWideChar(CP_ACP, 0, propvar->u.pszVal, -1, buf, len+1);
> + }
> + else
> + {
> + /* TODO: allocate large buffer, copy truncated result */
> + FIXME("Truncating narrow string not implemented\n");
> + hr = E_NOTIMPL;
> + }
> + break;
> + }
Same.
> +/* FIXME: It is 2015, why do I have to write this? */
> +static UINT i64_to_wstr(LONGLONG llVal, WCHAR *buf)
Maybe you could reuse VarBstrFromUI8() from oleaut32?
> + if (len < cch)
> + {
> + memcpy(buf, propvar->u.bstrVal, len*sizeof(WCHAR));
> + buf[len] = 0;
> + }
Isn't it what strcpyW does? This pattern appears in several places.
> + hr = PropVariantToString_Size(prop, &size);
> + if (FAILED(hr))
> + return hr;
> +
> + *pbuf = CoTaskMemAlloc((size+1) * sizeof(WCHAR));
> + if (!*pbuf)
> + return E_OUTOFMEMORY;
> +
> + hr = PropVariantToString(prop, *pbuf, size+1);
> + if (FAILED(hr))
> + {
> + CoTaskMemFree(*pbuf);
> + *pbuf = NULL;
> + }
> +
> + return hr;
It's the only place where PropVariantToString_Size is used, so you could
as well return full length from it.
> + ULONGLONG ullVal = 0xDEAFBABECAFEBEEF;
I think we prefer lower case hex literals these days.
More information about the wine-devel
mailing list