xwin: replace ZeroMemory()
replace Windows specific ZeroMemory (macro just calling memset()) by static initialization, calloc() and memset(). Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
This commit is contained in:
parent
c444223da3
commit
7bd19a9580
|
@ -58,15 +58,12 @@ winAllocatePrivates(ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for the screen private structure */
|
/* Allocate memory for the screen private structure */
|
||||||
pScreenPriv = malloc(sizeof(winPrivScreenRec));
|
pScreenPriv = calloc(sizeof(winPrivScreenRec), 1);
|
||||||
if (!pScreenPriv) {
|
if (!pScreenPriv) {
|
||||||
ErrorF("winAllocateScreenPrivates - malloc () failed\n");
|
ErrorF("winAllocateScreenPrivates - malloc () failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the memory of the private structure */
|
|
||||||
ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));
|
|
||||||
|
|
||||||
/* Initialize private structure members */
|
/* Initialize private structure members */
|
||||||
pScreenPriv->fActive = TRUE;
|
pScreenPriv->fActive = TRUE;
|
||||||
|
|
||||||
|
@ -143,15 +140,12 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for our private structure */
|
/* Allocate memory for our private structure */
|
||||||
pCmapPriv = malloc(sizeof(winPrivCmapRec));
|
pCmapPriv = calloc(sizeof(winPrivCmapRec), 1);
|
||||||
if (!pCmapPriv) {
|
if (!pCmapPriv) {
|
||||||
ErrorF("winAllocateCmapPrivates - malloc () failed\n");
|
ErrorF("winAllocateCmapPrivates - malloc () failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the memory of the private structure */
|
|
||||||
ZeroMemory(pCmapPriv, sizeof(winPrivCmapRec));
|
|
||||||
|
|
||||||
/* Register our colourmap private */
|
/* Register our colourmap private */
|
||||||
if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
|
if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
|
||||||
ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
|
ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
|
||||||
|
|
|
@ -512,14 +512,12 @@ winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
|
||||||
static Bool
|
static Bool
|
||||||
winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
|
winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
|
||||||
{
|
{
|
||||||
APPBARDATA abd;
|
APPBARDATA abd = (APPBARDATA) {
|
||||||
HWND hwndAutoHide;
|
.cbSize = sizeof(APPBARDATA),
|
||||||
|
.uEdge = uEdge
|
||||||
|
};
|
||||||
|
|
||||||
ZeroMemory(&abd, sizeof(abd));
|
HWND hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
|
||||||
abd.cbSize = sizeof(abd);
|
|
||||||
abd.uEdge = uEdge;
|
|
||||||
|
|
||||||
hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
|
|
||||||
if (hwndAutoHide != NULL) {
|
if (hwndAutoHide != NULL) {
|
||||||
/*
|
/*
|
||||||
Found an autohide taskbar on that edge, but is it on the
|
Found an autohide taskbar on that edge, but is it on the
|
||||||
|
@ -541,15 +539,15 @@ winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
|
||||||
static Bool
|
static Bool
|
||||||
winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
|
winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
|
||||||
{
|
{
|
||||||
APPBARDATA abd;
|
APPBARDATA abd = (APPBARDATA) {
|
||||||
|
.cbSize = sizeof(APPBARDATA)
|
||||||
|
};
|
||||||
|
|
||||||
winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
|
winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
|
||||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||||
|
|
||||||
/* Find out if the Windows taskbar is set to auto-hide */
|
/* Find out if the Windows taskbar is set to auto-hide */
|
||||||
ZeroMemory(&abd, sizeof(abd));
|
|
||||||
abd.cbSize = sizeof(abd);
|
|
||||||
if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
|
if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
|
||||||
winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
|
winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
|
||||||
|
|
||||||
|
|
|
@ -1395,9 +1395,9 @@ winInitWM(void **ppWMInfo,
|
||||||
pthread_mutex_t * ppmServerStarted,
|
pthread_mutex_t * ppmServerStarted,
|
||||||
int dwScreen, HWND hwndScreen, Bool compositeWM)
|
int dwScreen, HWND hwndScreen, Bool compositeWM)
|
||||||
{
|
{
|
||||||
WMProcArgPtr pArg = malloc(sizeof(WMProcArgRec));
|
WMProcArgPtr pArg = calloc(sizeof(WMProcArgRec), 1);
|
||||||
WMInfoPtr pWMInfo = malloc(sizeof(WMInfoRec));
|
WMInfoPtr pWMInfo = calloc(sizeof(WMInfoRec), 1);
|
||||||
XMsgProcArgPtr pXMsgArg = malloc(sizeof(XMsgProcArgRec));
|
XMsgProcArgPtr pXMsgArg = calloc(sizeof(XMsgProcArgRec), 1);
|
||||||
|
|
||||||
/* Bail if the input parameters are bad */
|
/* Bail if the input parameters are bad */
|
||||||
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
|
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
|
||||||
|
@ -1408,11 +1408,6 @@ winInitWM(void **ppWMInfo,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero the allocated memory */
|
|
||||||
ZeroMemory(pArg, sizeof(WMProcArgRec));
|
|
||||||
ZeroMemory(pWMInfo, sizeof(WMInfoRec));
|
|
||||||
ZeroMemory(pXMsgArg, sizeof(XMsgProcArgRec));
|
|
||||||
|
|
||||||
/* Set a return pointer to the Window Manager info structure */
|
/* Set a return pointer to the Window Manager info structure */
|
||||||
*ppWMInfo = pWMInfo;
|
*ppWMInfo = pWMInfo;
|
||||||
pWMInfo->fCompositeWM = compositeWM;
|
pWMInfo->fCompositeWM = compositeWM;
|
||||||
|
|
|
@ -621,13 +621,11 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
/* Are we tracking yet? */
|
/* Are we tracking yet? */
|
||||||
if (!s_fTracking) {
|
if (!s_fTracking) {
|
||||||
TRACKMOUSEEVENT tme;
|
TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
|
||||||
|
.cbSize = sizeof(TRACKMOUSEEVENT),
|
||||||
/* Setup data structure */
|
.dwFlags = TME_LEAVE,
|
||||||
ZeroMemory(&tme, sizeof(tme));
|
.hwndTrack = hwnd,
|
||||||
tme.cbSize = sizeof(tme);
|
};
|
||||||
tme.dwFlags = TME_LEAVE;
|
|
||||||
tme.hwndTrack = hwnd;
|
|
||||||
|
|
||||||
/* Call the tracking function */
|
/* Call the tracking function */
|
||||||
if (!TrackMouseEvent(&tme))
|
if (!TrackMouseEvent(&tme))
|
||||||
|
|
|
@ -98,16 +98,14 @@ winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
winScreenPriv(pScreen);
|
winScreenPriv(pScreen);
|
||||||
HRESULT ddrval = DD_OK;
|
HRESULT ddrval = DD_OK;
|
||||||
DDSURFACEDESC2 ddsd;
|
DDSURFACEDESC2 ddsd = (DDSURFACEDESC2) {
|
||||||
|
.dwSize = sizeof(DDSURFACEDESC2),
|
||||||
|
.dwFlags = DDSD_CAPS,
|
||||||
|
.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE
|
||||||
|
};
|
||||||
|
|
||||||
winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
|
winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
|
||||||
|
|
||||||
/* Describe the primary surface */
|
|
||||||
ZeroMemory(&ddsd, sizeof(ddsd));
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_CAPS;
|
|
||||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
||||||
|
|
||||||
/* Create the primary surface */
|
/* Create the primary surface */
|
||||||
ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
|
ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
|
||||||
&ddsd,
|
&ddsd,
|
||||||
|
@ -195,9 +193,10 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
winScreenPriv(pScreen);
|
winScreenPriv(pScreen);
|
||||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||||
HRESULT ddrval = DD_OK;
|
HRESULT ddrval = DD_OK;
|
||||||
DDSURFACEDESC2 ddsdShadow;
|
|
||||||
char *lpSurface = NULL;
|
char *lpSurface = NULL;
|
||||||
DDPIXELFORMAT ddpfPrimary;
|
DDPIXELFORMAT ddpfPrimary = (DDPIXELFORMAT) {
|
||||||
|
.dwSize = sizeof(DDPIXELFORMAT)
|
||||||
|
};
|
||||||
|
|
||||||
#if CYGDEBUG
|
#if CYGDEBUG
|
||||||
winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n",
|
winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n",
|
||||||
|
@ -211,18 +210,12 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
pScreenInfo->dwBPP);
|
pScreenInfo->dwBPP);
|
||||||
|
|
||||||
/* Allocate memory for our shadow surface */
|
/* Allocate memory for our shadow surface */
|
||||||
lpSurface = malloc(pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
|
lpSurface = calloc(pScreenInfo->dwPaddedWidth, pScreenInfo->dwHeight);
|
||||||
if (lpSurface == NULL) {
|
if (lpSurface == NULL) {
|
||||||
ErrorF("winAllocateFBShadowDDNL - Could not allocate bits\n");
|
ErrorF("winAllocateFBShadowDDNL - Could not allocate bits\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the framebuffer memory so we don't get a
|
|
||||||
* strange display at startup
|
|
||||||
*/
|
|
||||||
ZeroMemory(lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
|
|
||||||
|
|
||||||
/* Create a clipper */
|
/* Create a clipper */
|
||||||
ddrval = (*g_fpDirectDrawCreateClipper) (0,
|
ddrval = (*g_fpDirectDrawCreateClipper) (0,
|
||||||
&pScreenPriv->pddcPrimary, NULL);
|
&pScreenPriv->pddcPrimary, NULL);
|
||||||
|
@ -275,7 +268,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
|
|
||||||
/* Are we full screen? */
|
/* Are we full screen? */
|
||||||
if (pScreenInfo->fFullScreen) {
|
if (pScreenInfo->fFullScreen) {
|
||||||
DDSURFACEDESC2 ddsdCurrent;
|
|
||||||
DWORD dwRefreshRateCurrent = 0;
|
DWORD dwRefreshRateCurrent = 0;
|
||||||
HDC hdc = NULL;
|
HDC hdc = NULL;
|
||||||
|
|
||||||
|
@ -295,8 +287,9 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
* if a refresh rate has been passed on the command line.
|
* if a refresh rate has been passed on the command line.
|
||||||
*/
|
*/
|
||||||
if (pScreenInfo->dwRefreshRate != 0) {
|
if (pScreenInfo->dwRefreshRate != 0) {
|
||||||
ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
|
DDSURFACEDESC2 ddsdCurrent = (DDSURFACEDESC2) {
|
||||||
ddsdCurrent.dwSize = sizeof(ddsdCurrent);
|
.dwSize = sizeof(DDSURFACEDESC2)
|
||||||
|
};
|
||||||
|
|
||||||
/* Get information about current display settings */
|
/* Get information about current display settings */
|
||||||
ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4,
|
ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4,
|
||||||
|
@ -390,8 +383,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get primary surface's pixel format */
|
/* Get primary surface's pixel format */
|
||||||
ZeroMemory(&ddpfPrimary, sizeof(ddpfPrimary));
|
|
||||||
ddpfPrimary.dwSize = sizeof(ddpfPrimary);
|
|
||||||
ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4,
|
ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4,
|
||||||
&ddpfPrimary);
|
&ddpfPrimary);
|
||||||
if (FAILED(ddrval)) {
|
if (FAILED(ddrval)) {
|
||||||
|
@ -418,16 +409,17 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
|
||||||
* so you shouldn't be allocating video memory when
|
* so you shouldn't be allocating video memory when
|
||||||
* you have the option of using system memory instead.
|
* you have the option of using system memory instead.
|
||||||
*/
|
*/
|
||||||
ZeroMemory(&ddsdShadow, sizeof(ddsdShadow));
|
DDSURFACEDESC2 ddsdShadow = (DDSURFACEDESC2) {
|
||||||
ddsdShadow.dwSize = sizeof(ddsdShadow);
|
.dwSize = sizeof(ddsdShadow),
|
||||||
ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
|
.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
|
||||||
| DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
|
| DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT,
|
||||||
ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
|
||||||
ddsdShadow.dwHeight = pScreenInfo->dwHeight;
|
.dwHeight = pScreenInfo->dwHeight,
|
||||||
ddsdShadow.dwWidth = pScreenInfo->dwWidth;
|
.dwWidth = pScreenInfo->dwWidth,
|
||||||
ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
|
.u1.lPitch = pScreenInfo->dwPaddedWidth,
|
||||||
ddsdShadow.lpSurface = lpSurface;
|
.lpSurface = lpSurface,
|
||||||
ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
|
.u4.ddpfPixelFormat = ddpfPrimary
|
||||||
|
};
|
||||||
|
|
||||||
winDebug("winAllocateFBShadowDDNL - lPitch: %d\n",
|
winDebug("winAllocateFBShadowDDNL - lPitch: %d\n",
|
||||||
(int) pScreenInfo->dwPaddedWidth);
|
(int) pScreenInfo->dwPaddedWidth);
|
||||||
|
|
|
@ -106,7 +106,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize our bitmap info header */
|
/* Initialize our bitmap info header */
|
||||||
ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
memset(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD), 1);
|
||||||
pbmih->biSize = sizeof(BITMAPINFOHEADER);
|
pbmih->biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
|
||||||
/* Get the biBitCount */
|
/* Get the biBitCount */
|
||||||
|
@ -1162,18 +1162,14 @@ winCreateColormapShadowGDI(ColormapPtr pColormap)
|
||||||
dwEntriesMax = pVisual->ColormapEntries;
|
dwEntriesMax = pVisual->ColormapEntries;
|
||||||
|
|
||||||
/* Allocate a Windows logical color palette with max entries */
|
/* Allocate a Windows logical color palette with max entries */
|
||||||
lpPaletteNew = malloc(sizeof(LOGPALETTE)
|
lpPaletteNew = calloc(sizeof(LOGPALETTE)
|
||||||
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
|
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY), 1);
|
||||||
if (lpPaletteNew == NULL) {
|
if (lpPaletteNew == NULL) {
|
||||||
ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
|
ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
|
||||||
"with %d entries\n", (int) dwEntriesMax);
|
"with %d entries\n", (int) dwEntriesMax);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero out the colormap */
|
|
||||||
ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE)
|
|
||||||
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
|
|
||||||
|
|
||||||
/* Set the logical palette structure */
|
/* Set the logical palette structure */
|
||||||
lpPaletteNew->palVersion = 0x0300;
|
lpPaletteNew->palVersion = 0x0300;
|
||||||
lpPaletteNew->palNumEntries = dwEntriesMax;
|
lpPaletteNew->palNumEntries = dwEntriesMax;
|
||||||
|
|
|
@ -711,13 +711,11 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
/* Are we tracking yet? */
|
/* Are we tracking yet? */
|
||||||
if (!s_fTracking) {
|
if (!s_fTracking) {
|
||||||
TRACKMOUSEEVENT tme;
|
TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
|
||||||
|
tme.cbSize = sizeof(tme),
|
||||||
/* Setup data structure */
|
tme.dwFlags = TME_LEAVE,
|
||||||
ZeroMemory(&tme, sizeof(tme));
|
tme.hwndTrack = hwnd
|
||||||
tme.cbSize = sizeof(tme);
|
};
|
||||||
tme.dwFlags = TME_LEAVE;
|
|
||||||
tme.hwndTrack = hwnd;
|
|
||||||
|
|
||||||
/* Call the tracking function */
|
/* Call the tracking function */
|
||||||
if (!TrackMouseEvent(&tme))
|
if (!TrackMouseEvent(&tme))
|
||||||
|
|
10
os/utils.c
10
os/utils.c
|
@ -1492,15 +1492,13 @@ Win32TempDir(void)
|
||||||
int
|
int
|
||||||
System(const char *cmdline)
|
System(const char *cmdline)
|
||||||
{
|
{
|
||||||
STARTUPINFO si;
|
STARTUPINFO si = (STARTUPINFO) {
|
||||||
PROCESS_INFORMATION pi;
|
.cb = sizeof(si),
|
||||||
|
};
|
||||||
|
PROCESS_INFORMATION pi = (PROCESS_INFORMATION){0};
|
||||||
DWORD dwExitCode;
|
DWORD dwExitCode;
|
||||||
char *cmd = strdup(cmdline);
|
char *cmd = strdup(cmdline);
|
||||||
|
|
||||||
ZeroMemory(&si, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
ZeroMemory(&pi, sizeof(pi));
|
|
||||||
|
|
||||||
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||||
LPVOID buffer;
|
LPVOID buffer;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue