Re: VS 2015 support in src/tools/msvc - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: VS 2015 support in src/tools/msvc
Date
Msg-id CAB7nPqSOPynjV7ZC9wghkvwTpDPj7U=py7AoczzguTmv1kmh+g@mail.gmail.com
Whole thread Raw
In response to Re: VS 2015 support in src/tools/msvc  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: VS 2015 support in src/tools/msvc  (Christian Ullrich <chris@chrullrich.net>)
List pgsql-hackers
On Sat, Apr 9, 2016 at 7:41 AM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On Sat, Apr 9, 2016 at 1:46 AM, Christian Ullrich <chris@chrullrich.net> wrote:
>> * Andrew Dunstan wrote:
>>> On 04/08/2016 11:02 AM, Christian Ullrich wrote:
>>>>   src/port/chklocale.c(233): warning C4133: 'function': incompatible
>>>>   types - from 'const char *' to 'LPCWSTR' [...\postgres.vcxproj]
>>
>>> Do you have a fix for the LPCWSTR parameter issue?
>>
>> As long as the locale short name cannot contain characters outside of ASCII,
>> and I don't see how it could, just the typical measure-allocate-convert
>> dance, add error handling to taste:
>>
>> int res = MultiByteToWideChar(CP_ACP, 0, ctype, -1, NULL, 0);
>> WCHAR *wctype = malloc(res * sizeof(WCHAR));
>> memset(wctype, 0, res * sizeof(WCHAR));
>> res = MultiByteToWideChar(CP_ACP, 0, ctype, -1, wctype, wctypelen);

I don't think that's good to use malloc in those code paths, and I
think that we cannot use palloc as well for a buffer passed directly
into this function, so it looks that we had better use a fix-sized
buffer and allocate the output into that. What would be a a correct
estimation of the maximum size we should allow? 80 (similar to
pg_locale.c)?
-- 
Michael



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: closing CommitFest 2016-03, feature freeze now in effect
Next
From: Christian Ullrich
Date:
Subject: Re: VS 2015 support in src/tools/msvc