Alexandre Julliard : kernel32: Simplify GetGeoInfoA() implementation.
Alexandre Julliard
julliard at winehq.org
Wed Apr 6 16:09:00 CDT 2022
Module: wine
Branch: master
Commit: bf83236b2f36c6222ba0acde3a13737cd4c4599d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bf83236b2f36c6222ba0acde3a13737cd4c4599d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Apr 6 10:10:17 2022 +0200
kernel32: Simplify GetGeoInfoA() implementation.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/locale.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 020ec3d843d..4c815be43cc 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -381,30 +381,10 @@ BOOL WINAPI EnumUILanguagesA( UILANGUAGE_ENUMPROCA proc, DWORD flags, LONG_PTR p
*/
INT WINAPI GetGeoInfoA(GEOID geoid, GEOTYPE geotype, LPSTR data, int data_len, LANGID lang)
{
- WCHAR *buffW;
- INT len;
+ WCHAR buffer[256];
TRACE("%ld %ld %p %d %d\n", geoid, geotype, data, data_len, lang);
- len = GetGeoInfoW(geoid, geotype, NULL, 0, lang);
- if (!len)
- return 0;
-
- buffW = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- if (!buffW)
- return 0;
-
- GetGeoInfoW(geoid, geotype, buffW, len, lang);
- len = WideCharToMultiByte(CP_ACP, 0, buffW, -1, NULL, 0, NULL, NULL);
- if (!data || !data_len) {
- HeapFree(GetProcessHeap(), 0, buffW);
- return len;
- }
-
- len = WideCharToMultiByte(CP_ACP, 0, buffW, -1, data, data_len, NULL, NULL);
- HeapFree(GetProcessHeap(), 0, buffW);
-
- if (data_len < len)
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return data_len < len ? 0 : len;
+ if (!GetGeoInfoW( geoid, geotype, buffer, ARRAY_SIZE(buffer), lang )) return 0;
+ return WideCharToMultiByte( CP_ACP, 0, buffer, -1, data, data_len, NULL, NULL );
}
More information about the wine-cvs
mailing list