diff --git a/hw/xnest/Font.c b/hw/xnest/Font.c index eff88f5d9..602a8aa03 100644 --- a/hw/xnest/Font.c +++ b/hw/xnest/Font.c @@ -37,7 +37,6 @@ int xnestFontPrivateIndex; Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) { - void *priv; Atom name_atom, value_atom; int nprops; FontPropPtr props; @@ -66,7 +65,7 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) if (!name) return FALSE; - priv = (void *) malloc(sizeof(xnestPrivFont)); + void *priv = calloc(1, sizeof(xnestPrivFont)); xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv); xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name); diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index bab6096b1..ca0997042 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -167,10 +167,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec)); numVisuals = 0; - depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec)); + depths = calloc(MAXDEPTH, sizeof(DepthRec)); depths[0].depth = 1; depths[0].numVids = 0; - depths[0].vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); + depths[0].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID)); numDepths = 1; for (i = 0; i < xnestNumVisuals; i++) { @@ -217,8 +217,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) depthIndex = numDepths; depths[depthIndex].depth = xnestVisuals[i].depth; depths[depthIndex].numVids = 0; - depths[depthIndex].vids = - (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); + depths[depthIndex].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID)); numDepths++; } if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) {