From f8a1f79b30f5996109646d890b39d9453342a7b9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 25 Jul 2019 23:53:57 +0200 Subject: Colormap.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Colormap.c | 28 +++++++++------------------ 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c index 33b0738ec..7fa006539 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c @@ -187,9 +187,7 @@ static int nxagentCountInstalledColormapWindows(WindowPtr pWin, void * ptr) { nxagentInstalledColormapWindows *icws = (nxagentInstalledColormapWindows *) ptr; - int i; - - for (i = 0; i < icws->numCmapIDs; i++) + for (int i = 0; i < icws->numCmapIDs; i++) if (SEARCH_PREDICATE) { icws->numWindows++; return WT_DONTWALKCHILDREN; @@ -201,9 +199,8 @@ static int nxagentCountInstalledColormapWindows(WindowPtr pWin, void * ptr) static int nxagentGetInstalledColormapWindows(WindowPtr pWin, void * ptr) { nxagentInstalledColormapWindows *icws = (nxagentInstalledColormapWindows *)ptr; - int i; - for (i = 0; i < icws->numCmapIDs; i++) + for (int i = 0; i < icws->numCmapIDs; i++) if (SEARCH_PREDICATE) { icws->windows[icws->index++] = nxagentWindow(pWin); return WT_DONTWALKCHILDREN; @@ -262,10 +259,9 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) #ifdef _XSERVER64 { - int i; Window64 *windows = (Window64 *)malloc(numWindows * sizeof(Window64)); - for(i = 0; i < numWindows; ++i) + for(int i = 0; i < numWindows; ++i) windows[i] = icws.windows[i]; XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], windows, numWindows); @@ -347,17 +343,14 @@ void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen) void nxagentDirectInstallColormaps(ScreenPtr pScreen) { - int i, n; Colormap pCmapIDs[MAXCMAPS]; if (!nxagentDoDirectColormaps) return; - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); - - for (i = 0; i < n; i++) { - ColormapPtr pCmap; + int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); - pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); + for (int i = 0; i < n; i++) { + ColormapPtr pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); if (pCmap) XInstallColormap(nxagentDisplay, nxagentColormap(pCmap)); } @@ -365,14 +358,13 @@ void nxagentDirectInstallColormaps(ScreenPtr pScreen) void nxagentDirectUninstallColormaps(ScreenPtr pScreen) { - int i, n; Colormap pCmapIDs[MAXCMAPS]; if (!nxagentDoDirectColormaps) return; - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); + int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); - for (i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { ColormapPtr pCmap; pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); @@ -429,7 +421,6 @@ int nxagentListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds) if (nxagentInstalledDefaultColormap) { *pCmapIds = InstalledMaps[pScreen->myNum]->mid; - return 1; } else @@ -443,10 +434,9 @@ void nxagentStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors) if (pCmap->pVisual->class & DynamicClass) #ifdef _XSERVER64 { - int i; XColor *pColors64 = (XColor *)malloc(nColors * sizeof(XColor) ); - for(i = 0; i < nColors; ++i) + for(int i = 0; i < nColors; ++i) { pColors64[i].pixel = pColors[i].pixel; pColors64[i].red = pColors[i].red; -- cgit v1.2.3