diff --git a/xfixes/cursor.c b/xfixes/cursor.c index a2c4159d1..d1d9bff0e 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -230,7 +230,7 @@ XFixesSelectCursorInput(ClientPtr pClient, WindowPtr pWindow, CARD32 eventMask) return Success; } if (!e) { - e = (CursorEventPtr) malloc(sizeof(CursorEventRec)); + e = calloc(1, sizeof(CursorEventRec)); if (!e) return BadAlloc; @@ -362,7 +362,6 @@ int ProcXFixesGetCursorImage(ClientPtr client) { /* REQUEST(xXFixesGetCursorImageReq); */ - xXFixesGetCursorImageReply *rep; CursorPtr pCursor; CARD32 *image; int npixels, width, height, rc, x, y; @@ -379,7 +378,8 @@ ProcXFixesGetCursorImage(ClientPtr client) width = pCursor->bits->width; height = pCursor->bits->height; npixels = width * height; - rep = calloc(1, + + xXFixesGetCursorImageReply *rep = calloc(1, sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32)); if (!rep) return BadAlloc; @@ -502,7 +502,6 @@ int ProcXFixesGetCursorImageAndName(ClientPtr client) { /* REQUEST(xXFixesGetCursorImageAndNameReq); */ - xXFixesGetCursorImageAndNameReply *rep; CursorPtr pCursor; CARD32 *image; int npixels; @@ -526,7 +525,9 @@ ProcXFixesGetCursorImageAndName(ClientPtr client) name = pCursor->name ? NameForAtom(pCursor->name) : ""; nbytes = strlen(name); nbytesRound = pad_to_int32(nbytes); - rep = calloc(1, sizeof(xXFixesGetCursorImageAndNameReply) + + + xXFixesGetCursorImageAndNameReply *rep = calloc(1, + sizeof(xXFixesGetCursorImageAndNameReply) + npixels * sizeof(CARD32) + nbytesRound); if (!rep) return BadAlloc; @@ -766,9 +767,7 @@ static int createCursorHideCount(ClientPtr pClient, ScreenPtr pScreen) { CursorScreenPtr cs = GetCursorScreen(pScreen); - CursorHideCountPtr pChc; - - pChc = (CursorHideCountPtr) malloc(sizeof(CursorHideCountRec)); + CursorHideCountPtr pChc = calloc(1, sizeof(CursorHideCountRec)); if (pChc == NULL) { return BadAlloc; } @@ -1064,9 +1063,7 @@ XFixesCursorInit(void) for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; - CursorScreenPtr cs; - - cs = (CursorScreenPtr) calloc(1, sizeof(CursorScreenRec)); + CursorScreenPtr cs = calloc(1, sizeof(CursorScreenRec)); if (!cs) return FALSE; Wrap(cs, pScreen, CloseScreen, CursorCloseScreen); diff --git a/xfixes/select.c b/xfixes/select.c index 665a288aa..1e8c7ee45 100644 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -142,7 +142,7 @@ XFixesSelectSelectionInput(ClientPtr pClient, return Success; } if (!e) { - e = (SelectionEventPtr) malloc(sizeof(SelectionEventRec)); + e = calloc(1, sizeof(SelectionEventRec)); if (!e) return BadAlloc;