msdmo: Array parameter is passed to function as pointer so loses size information

Andrew Talbot Andrew.Talbot at talbotville.com
Wed Apr 9 11:54:53 CDT 2008


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".

> If you want to pick up errors like passing the wrong size into functions
> then I would suggest using an automatic checker that is able to use
> semantic information, like Microsoft's PREfast.
> 

Your implied presumption may not be correct. 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.

-- 
Andy.





More information about the wine-devel mailing list