ddraw: Avoid clearing some memory unnecessarily.
This commit is contained in:
parent
953c7a3427
commit
3871329872
|
@ -3125,10 +3125,8 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
|
||||||
DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
|
DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
|
||||||
|
|
||||||
/* Modify some flags */
|
/* Modify some flags */
|
||||||
memset(&desc2, 0, sizeof(desc2));
|
|
||||||
desc2.dwSize = sizeof(desc2); /* For the struct copy */
|
desc2.dwSize = sizeof(desc2); /* For the struct copy */
|
||||||
DD_STRUCT_COPY_BYSIZE(&desc2, DDSD);
|
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 */
|
desc2.u4.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); /* Just to be sure */
|
||||||
|
|
||||||
/* Get the video mode from WineD3D - we will need it */
|
/* Get the video mode from WineD3D - we will need it */
|
||||||
|
|
|
@ -591,15 +591,10 @@ typedef struct
|
||||||
#define DD_STRUCT_COPY_BYSIZE(to,from) \
|
#define DD_STRUCT_COPY_BYSIZE(to,from) \
|
||||||
do { \
|
do { \
|
||||||
DWORD __size = (to)->dwSize; \
|
DWORD __size = (to)->dwSize; \
|
||||||
DWORD __copysize = __size; \
|
DWORD __copysize = min(__size, (from)->dwSize); \
|
||||||
DWORD __resetsize = __size; \
|
|
||||||
assert(to != from); \
|
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); \
|
memcpy(to, from, __copysize); \
|
||||||
|
memset((char*)(to) + __copysize, 0, __size - __copysize); \
|
||||||
(to)->dwSize = __size; /* restore size */ \
|
(to)->dwSize = __size; /* restore size */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue