windowscodecs: Fix *_CopyPixels functions to properly handle a NULL rectangle
David Laight
david at l8s.co.uk
Mon Oct 18 15:20:34 CDT 2010
On Mon, Oct 18, 2010 at 08:51:49PM +0200, Krzysztof Nowicki wrote:
> W dniu 17.10.2010 18:49, Vitaliy Margolen pisze:
> >On 10/17/2010 01:59 AM, Krzysztof Nowicki wrote:
> >>Doing a memcpy to a local rectangle seems a morenatural way to do it
> >
> >Not really. Doing RECT = RECT is the natural way to do it. Don't use
> >memcpy to copy one structure to another structure of the same type.
> >
> >Vitaliy.
> >
>
> Where I come from copying structures directly is considered bad practice
> and it's safer to use memcpy. We had problems before with broken
> compilers that would try to do some black magic in such cases. So the
> policy was to use memcpy for structures because it's safer. A good
> compiler will inline such a memcpy anyway.
Actually, for a normal application, the compiler knows what memcpy()
does and can make assumptions based on the actual structure type
involved. This can cause extreme grief if you try to copy from a
misaligned pointer into a local variable (strictly, in valid C, you
can never get a misaligned pointer - and the compiler will use
word accesses).
David
--
David Laight: david at l8s.co.uk
More information about the wine-devel
mailing list