Statically assigning structs containing WCHAR strings

Andrew Eikum aeikum at codeweavers.com
Fri Oct 24 13:32:40 CDT 2014


On Fri, Oct 24, 2014 at 06:58:22PM +0200, Jonathan Vollebregt wrote:
> * Assign each string to a variable and assign each variable to the
> struct: [1]
> 
> This has a lot of lines of code, and personally I think it almost
> looks worse than what was there before.
> 
> * Make the structs use arrays: [2]
> 
> This brings the fixed length issue, but it seems much cleaner than [1]
> 
> Is there any reason to prefer [1] to [2]? Is there a better way of
> doing this?
> 
> [1] https://github.com/jnvsor/wine/commit/9efaba8c3
> [2] https://github.com/jnvsor/wine/commit/80ee795c1
> 

I'd pick [1]. I think it reflects the situation better: you're
pointing to strings of arbitrary length, not 5- or 20-char arrays.  It
also means you don't have to update the array length if you were to
add a longer string in the future.

First similar example I found was in test_StrStrW() in
<dlls/shlwapi/tests/string.c>.

Andrew



More information about the wine-devel mailing list