diff --git a/composite/compalloc.c b/composite/compalloc.c index 4a1243170..56d17820b 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -134,7 +134,6 @@ int compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) { CompWindowPtr cw = GetCompWindow(pWin); - CompClientWindowPtr ccw; CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen); WindowPtr pLayerWin; Bool anyMarked = FALSE; @@ -151,7 +150,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) * Only one Manual update is allowed */ if (cw && update == CompositeRedirectManual) - for (ccw = cw->clients; ccw; ccw = ccw->next) + for (CompClientWindowPtr ccw = cw->clients; ccw; ccw = ccw->next) if (ccw->update == CompositeRedirectManual) return BadAccess; @@ -160,7 +159,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) * The client *could* allocate multiple, but while supported, * it is not expected to be common */ - ccw = malloc(sizeof(CompClientWindowRec)); + CompClientWindowPtr ccw = calloc(1, sizeof(CompClientWindowRec)); if (!ccw) return BadAlloc; ccw->id = FakeClientID(pClient->index); @@ -169,7 +168,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) * Now make sure there's a per-window structure to hang this from */ if (!cw) { - cw = malloc(sizeof(CompWindowRec)); + cw = calloc(1, sizeof(CompWindowRec)); if (!cw) { free(ccw); return BadAlloc; @@ -342,14 +341,13 @@ int compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update) { CompSubwindowsPtr csw = GetCompSubwindows(pWin); - CompClientWindowPtr ccw; WindowPtr pChild; /* * Only one Manual update is allowed */ if (csw && update == CompositeRedirectManual) - for (ccw = csw->clients; ccw; ccw = ccw->next) + for (CompClientWindowPtr ccw = csw->clients; ccw; ccw = ccw->next) if (ccw->update == CompositeRedirectManual) return BadAccess; /* @@ -357,7 +355,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update) * The client *could* allocate multiple, but while supported, * it is not expected to be common */ - ccw = malloc(sizeof(CompClientWindowRec)); + CompClientWindowPtr ccw = calloc(1, sizeof(CompClientWindowRec)); if (!ccw) return BadAlloc; ccw->id = FakeClientID(pClient->index); @@ -366,7 +364,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update) * Now make sure there's a per-window structure to hang this from */ if (!csw) { - csw = malloc(sizeof(CompSubwindowsRec)); + csw = calloc(1, sizeof(CompSubwindowsRec)); if (!csw) { free(ccw); return BadAlloc; diff --git a/composite/compext.c b/composite/compext.c index bb8f5946d..b55882974 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -700,7 +700,7 @@ PanoramiXCompositeNameWindowPixmap(ClientPtr client) LEGAL_NEW_RESOURCE(stuff->pixmap, client); - if (!(newPix = malloc(sizeof(PanoramiXRes)))) + if (!(newPix = calloc(1, sizeof(PanoramiXRes)))) return BadAlloc; newPix->type = XRT_PIXMAP; @@ -769,7 +769,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client) cs = GetCompScreen(screenInfo.screens[0]); if (!cs->pOverlayWin) { - if (!(overlayWin = malloc(sizeof(PanoramiXRes)))) + if (!(overlayWin = calloc(1, sizeof(PanoramiXRes)))) return BadAlloc; overlayWin->type = XRT_WINDOW; diff --git a/composite/compinit.c b/composite/compinit.c index e0a565365..79ce2ef3c 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -334,8 +334,6 @@ compAddAlternateVisuals(ScreenPtr pScreen, CompScreenPtr cs) Bool compScreenInit(ScreenPtr pScreen) { - CompScreenPtr cs; - if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) @@ -345,7 +343,7 @@ compScreenInit(ScreenPtr pScreen) if (GetCompScreen(pScreen)) return TRUE; - cs = (CompScreenPtr) malloc(sizeof(CompScreenRec)); + CompScreenPtr cs = calloc(1, sizeof(CompScreenRec)); if (!cs) return FALSE; diff --git a/composite/compoverlay.c b/composite/compoverlay.c index ffff34b7b..e2c4c58bf 100644 --- a/composite/compoverlay.c +++ b/composite/compoverlay.c @@ -96,9 +96,7 @@ CompOverlayClientPtr compCreateOverlayClient(ScreenPtr pScreen, ClientPtr pClient) { CompScreenPtr cs = GetCompScreen(pScreen); - CompOverlayClientPtr pOc; - - pOc = (CompOverlayClientPtr) malloc(sizeof(CompOverlayClientRec)); + CompOverlayClientPtr pOc = calloc(1, sizeof(CompOverlayClientRec)); if (pOc == NULL) return NULL;