Commit 0227b8cb authored by Benjamin Arai's avatar Benjamin Arai Committed by Alexandre Julliard

oleaut32: Removes extra string allocation for varformat:VarMonthName.

parent f5cc0f7d
...@@ -2471,7 +2471,6 @@ HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrO ...@@ -2471,7 +2471,6 @@ HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrO
{ {
DWORD localeValue; DWORD localeValue;
INT size; INT size;
WCHAR *str;
if ((iMonth < 1) || (iMonth > 12)) if ((iMonth < 1) || (iMonth > 12))
return E_INVALIDARG; return E_INVALIDARG;
...@@ -2489,18 +2488,14 @@ HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrO ...@@ -2489,18 +2488,14 @@ HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrO
ERR("GetLocaleInfo 0x%lx failed.\n", localeValue); ERR("GetLocaleInfo 0x%lx failed.\n", localeValue);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
str = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*size); *pbstrOut = SysAllocStringLen(NULL,size - 1);
if (!str) if (!*pbstrOut)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, str, size); size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, *pbstrOut, size);
if (!size) { if (!size) {
ERR("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue); ERR("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue);
HeapFree(GetProcessHeap(),0,str); SysFreeString(*pbstrOut);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
*pbstrOut = SysAllocString(str);
HeapFree(GetProcessHeap(),0,str);
if (!*pbstrOut)
return E_OUTOFMEMORY;
return S_OK; return S_OK;
} }
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