ddraw: Avoid clearing some memory unnecessarily.

This commit is contained in:
Dylan Smith 2011-05-23 17:58:36 -04:00 committed by Alexandre Julliard
parent 953c7a3427
commit 3871329872
2 changed files with 9 additions and 16 deletions

View File

@ -3125,10 +3125,8 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
/* Modify some flags */
memset(&desc2, 0, sizeof(desc2));
desc2.dwSize = sizeof(desc2); /* For the struct copy */
DD_STRUCT_COPY_BYSIZE(&desc2, DDSD);
desc2.dwSize = sizeof(desc2); /* To override a possibly smaller size */
desc2.u4.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); /* Just to be sure */
/* Get the video mode from WineD3D - we will need it */

View File

@ -591,15 +591,10 @@ typedef struct
#define DD_STRUCT_COPY_BYSIZE(to,from) \
do { \
DWORD __size = (to)->dwSize; \
DWORD __copysize = __size; \
DWORD __resetsize = __size; \
DWORD __copysize = min(__size, (from)->dwSize); \
assert(to != from); \
if (__resetsize > sizeof(*to)) \
__resetsize = sizeof(*to); \
memset(to,0,__resetsize); \
if ((from)->dwSize < __size) \
__copysize = (from)->dwSize; \
memcpy(to, from, __copysize); \
memset((char*)(to) + __copysize, 0, __size - __copysize); \
(to)->dwSize = __size; /* restore size */ \
} while (0)