shlwapi: Resupply array sizes stripped by function interface

Mikołaj Zalewski mikolaj at
Tue Sep 26 16:20:28 CDT 2006

Andrew Talbot wrote:

>Dan Kegel wrote:
>>BTW the way you define the new size, as a magic constant, seems
>>bad.  Can you use 4 * sizeof(WCHAR), or whatever, instead of 8?
>>And even then, the '4' seems almost as bad.
>>- Dan
>Yes, I did feel uneasy about using a magic constant, I must admit. Another
>way to handle it would be to call GetLocaleInfoW() twice for each buffer.
>The first time with its lpLCData parameter equal to NULL and its cchData
>parameter equal to zero, which should return the number of characters
>required for the buffer. The second time to then retrieve the required
>locale information. I had originally decided against this, because I felt
>that it might be over-engineering, but how does that sound to you?
  I've wrote that code and forgot that sizeof(parameter array) is the 
size of a pointer. The current code will actually work as in current 
wine there is no locale that has more than one character (plus the NUL 
terminator) for the decimal or thousand separator but it's better to fix 
it to use the whole buffer in case a locale with a strange separator is 
added. I've chosen the value 8 because I can't imagine a longer 
separator. I agree #defining a constant for it (and using it in 
FillNumberFmt, FormatInt, FormatDouble) would be good but writing it as 
4*sizeof(WCHAR) isn't a good idea as the fourth parameter is the number 
of characters, not the number of bytes.

Mikolaj Zalewski

More information about the wine-devel mailing list