msdmo: Array parameter is passed to function as pointer so loses size information
Robert Shearman
rob at codeweavers.com
Thu Apr 10 06:08:48 CDT 2008
Andrew Talbot wrote:
> Robert Shearman wrote:
>
>> This is incorrect. count is the size in bytes of the buffer passed in
>> (szName) and so should be sizeof(szName) not
>> sizeof(szName)/sizeof(szName[0]) (i.e. 80).
>>
>>
>
> Are you sure? MSDN says "szName: Array of 80 Unicode characters that
> receives the name of the DMO".
>
It doesn't matter what MSDN says about szName, RegQueryValueExW still
takes the size in bytes, not characters. I.e. count should be set to
NAME_SIZE * sizeof(WCHAR), not NAME_SIZE.
> But, in any case, when arrays
> are passed as arguments to functions they are converted to pointers, so
> sizeof(szName) would represent the size of a pointer to the array, not the
> size of the array itself.
I didn't realise this before but the attached test program prints:
$ ./atest
sizeof(array) = 4
So you are right. Still, my point stands that the code is still passing
in a smaller size than the size of the buffer and so is not correct.
--
Rob Shearman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atest.c
Type: text/x-csrc
Size: 166 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20080410/eaf8d2ee/attachment.c
More information about the wine-devel
mailing list