xserver: Branch 'master' - 2 commits

Adam Jackson ajax at kemper.freedesktop.org
Mon Oct 6 11:52:15 PDT 2008


 Xext/xres.c                               |    4 -
 Xi/exevents.c                             |    7 --
 dbe/dbe.c                                 |    3 -
 dix/devices.c                             |   74 ++----------------------------
 dix/dispatch.c                            |    6 --
 dix/glyphcurs.c                           |    4 -
 glx/glxcmds.c                             |    3 -
 glx/glxdri.c                              |   10 +---
 glx/glxdri2.c                             |   10 +---
 glx/glxdriswrast.c                        |   10 +---
 hw/dmx/config/dmxparse.c                  |    5 --
 hw/dmx/dmx.h                              |    6 --
 hw/dmx/dmxextension.c                     |    3 -
 hw/dmx/dmxstat.c                          |    3 -
 hw/dmx/glxProxy/glxcmds.c                 |    3 -
 hw/dmx/glxProxy/glxext.c                  |   13 +----
 hw/dmx/glxProxy/glxutil.c                 |    4 -
 hw/dmx/input/dmxbackend.c                 |    3 -
 hw/dmx/input/dmxconsole.c                 |    3 -
 hw/dmx/input/dmxmotion.c                  |    3 -
 hw/dmx/input/lnx-keyboard.c               |    3 -
 hw/dmx/input/lnx-ms.c                     |    3 -
 hw/dmx/input/lnx-ps2.c                    |    3 -
 hw/dmx/input/usb-common.c                 |    3 -
 hw/kdrive/ephyr/ephyr.c                   |    3 -
 hw/kdrive/fake/fake.c                     |    3 -
 hw/kdrive/fbdev/fbdev.c                   |    3 -
 hw/kdrive/linux/evdev.c                   |    6 --
 hw/kdrive/src/kdrive.c                    |    3 -
 hw/kdrive/src/kinfo.c                     |    6 --
 hw/kdrive/src/kinput.c                    |    4 -
 hw/kdrive/vesa/vesa.c                     |    6 --
 hw/xfree86/common/xf86AutoConfig.c        |    3 -
 hw/xfree86/common/xf86Configure.c         |   18 ++-----
 hw/xfree86/common/xf86xv.c                |    5 --
 hw/xfree86/int10/generic.c                |    6 +-
 hw/xfree86/os-support/bsd/libusb/parse.c  |    3 -
 hw/xfree86/os-support/bus/Sbus.c          |    2 
 hw/xfree86/os-support/bus/linuxPci.c      |    2 
 hw/xfree86/os-support/linux/int10/linux.c |    2 
 hw/xfree86/os-support/solaris/sun_init.c  |    4 -
 hw/xfree86/parser/Configint.h             |    6 --
 hw/xfree86/parser/read.c                  |    1 
 hw/xfree86/ramdac/xf86HWCurs.c            |    2 
 hw/xfree86/xaa/xaaCpyPlane.c              |    4 -
 hw/xfree86/xaa/xaaNonTEText.c             |    3 -
 hw/xquartz/GL/indirect.c                  |   11 +---
 hw/xwin/wincursor.c                       |    3 -
 hw/xwin/winmultiwindowicons.c             |    8 +--
 mi/mibitblt.c                             |    3 -
 render/glyph.c                            |    6 --
 render/picture.c                          |    3 -
 render/render.c                           |    6 --
 53 files changed, 87 insertions(+), 237 deletions(-)

New commits:
commit 8a5b89e8e184f4cbf33c6dee0b06e61d8f857576
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Oct 6 15:36:51 2008 -0400

    xalloc+memset(0) -> xcalloc

diff --git a/Xext/xres.c b/Xext/xres.c
index 75ade58..bdc534c 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -133,9 +133,7 @@ ProcXResQueryClientResources (ClientPtr client)
         return BadValue;
     }
 
-    counts = xalloc((lastResourceType + 1) * sizeof(int));
-
-    memset(counts, 0, (lastResourceType + 1) * sizeof(int));
+    counts = xcalloc(lastResourceType + 1, sizeof(int));
 
     FindAllClientResources(clients[clientID], ResFindAllRes, counts);
 
diff --git a/dix/devices.c b/dix/devices.c
index 5e0b68f..9d4ce34 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -147,13 +147,10 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
 
     if (devid >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
-    dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
+    dev =  xcalloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
     if (!dev)
 	return (DeviceIntPtr)NULL;
-    dev->name = (char *)NULL;
-    dev->type = 0;
     dev->id = devid;
-    dev->public.on = FALSE;
     dev->public.processInputProc = (ProcessInputProc)NoopDDA;
     dev->public.realInputProc = (ProcessInputProc)NoopDDA;
     dev->public.enqueueInputProc = EnqueueEvent;
@@ -161,51 +158,12 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
     dev->startup = autoStart;
 
     /* device grab defaults */
-    dev->deviceGrab.sync.frozen = FALSE;
-    dev->deviceGrab.sync.other = NullGrab;
-    dev->deviceGrab.sync.state = NOT_GRABBED;
-    dev->deviceGrab.sync.event = (xEvent *) NULL;
-    dev->deviceGrab.sync.evcount = 0;
-    dev->deviceGrab.grab = NullGrab;
     dev->deviceGrab.grabTime = currentTime;
-    dev->deviceGrab.fromPassiveGrab = FALSE;
-    dev->deviceGrab.implicitGrab = FALSE;
-
-    dev->key = (KeyClassPtr)NULL;
-    dev->valuator = (ValuatorClassPtr)NULL;
-    dev->button = (ButtonClassPtr)NULL;
-    dev->focus = (FocusClassPtr)NULL;
-    dev->proximity = (ProximityClassPtr)NULL;
-    dev->absolute = (AbsoluteClassPtr)NULL;
-    dev->kbdfeed = (KbdFeedbackPtr)NULL;
-    dev->ptrfeed = (PtrFeedbackPtr)NULL;
-    dev->intfeed = (IntegerFeedbackPtr)NULL;
-    dev->stringfeed = (StringFeedbackPtr)NULL;
-    dev->bell = (BellFeedbackPtr)NULL;
-    dev->leds = (LedFeedbackPtr)NULL;
-#ifdef XKB
-    dev->xkb_interest = NULL;
-#endif
-    dev->config_info = NULL;
-    dev->devPrivates = NULL;
-    dev->unwrapProc = NULL;
+
     dev->coreEvents = TRUE;
-    dev->inited = FALSE;
-    dev->enabled = FALSE;
 
     /* sprite defaults */
     dev->spriteInfo = (SpriteInfoPtr)&dev[1];
-    dev->spriteInfo->sprite = NULL;
-    dev->spriteInfo->spriteOwner = FALSE;
-
-    /* last valuators */
-    memset(dev->last.valuators, 0, sizeof(dev->last.valuators));
-    memset(dev->last.remainder, 0, sizeof(dev->last.remainder));
-    dev->last.numValuators = 0;
-
-    /* device properties */
-    dev->properties.properties = NULL;
-    dev->properties.handlers = NULL;
 
     /*  security creation/labeling check
      */
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 6e7637e..ab2d91b 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -164,11 +164,10 @@ static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen,
 {
     __GLXcontext *context;
 
-    context = xalloc (sizeof (__GLXcontext));
+    context = xcalloc (1, sizeof (__GLXcontext));
     if (context == NULL)
 	return NULL;
 
-    memset(context, 0, sizeof *context);
     context->destroy = __glXdirectContextDestroy;
 
     return context;
diff --git a/glx/glxdri.c b/glx/glxdri.c
index c33b5bd..ce098e1 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -613,11 +613,10 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
     if (baseShareContext && baseShareContext->isDirect)
         return NULL;
 
-    context = xalloc(sizeof *context);
+    context = xcalloc(1, sizeof *context);
     if (context == NULL)
 	return NULL;
 
-    memset(context, 0, sizeof *context);
     context->base.destroy           = __glXDRIcontextDestroy;
     context->base.makeCurrent       = __glXDRIcontextMakeCurrent;
     context->base.loseCurrent       = __glXDRIcontextLoseCurrent;
@@ -672,12 +671,10 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
     GLboolean retval;
     drm_drawable_t hwDrawable;
 
-    private = xalloc(sizeof *private);
+    private = xcalloc(1, sizeof *private);
     if (private == NULL)
 	return NULL;
 
-    memset(private, 0, sizeof *private);
-
     if (!__glXDrawableInit(&private->base, screen,
 			   pDraw, type, drawId, glxConfig)) {
         xfree(private);
@@ -950,10 +947,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 	return NULL;
     }
 
-    screen = xalloc(sizeof *screen);
+    screen = xcalloc(1, sizeof *screen);
     if (screen == NULL)
       return NULL;
-    memset(screen, 0, sizeof *screen);
 
     screen->base.destroy        = __glXDRIscreenDestroy;
     screen->base.createContext  = __glXDRIscreenCreateContext;
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 495de81..65138cd 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -279,11 +279,10 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
     else
 	driShare = NULL;
 
-    context = xalloc(sizeof *context);
+    context = xcalloc(1, sizeof *context);
     if (context == NULL)
 	return NULL;
 
-    memset(context, 0, sizeof *context);
     context->base.destroy           = __glXDRIcontextDestroy;
     context->base.makeCurrent       = __glXDRIcontextMakeCurrent;
     context->base.loseCurrent       = __glXDRIcontextLoseCurrent;
@@ -310,12 +309,10 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
     __GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
     __GLXDRIdrawable *private;
 
-    private = xalloc(sizeof *private);
+    private = xcalloc(1, sizeof *private);
     if (private == NULL)
 	return NULL;
 
-    memset(private, 0, sizeof *private);
-
     private->screen = driScreen;
     if (!__glXDrawableInit(&private->base, screen,
 			   pDraw, type, drawId, glxConfig)) {
@@ -464,10 +461,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     const __DRIconfig **driConfigs;
     int i;
 
-    screen = xalloc(sizeof *screen);
+    screen = xcalloc(1, sizeof *screen);
     if (screen == NULL)
 	return NULL;
-    memset(screen, 0, sizeof *screen);
 
     if (!xf86LoaderCheckSymbol("DRI2Connect") ||
 	!DRI2Connect(pScreen, &screen->fd, &driverName)) {
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index 2859704..b425012 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -265,11 +265,10 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
     else
 	driShare = NULL;
 
-    context = xalloc(sizeof *context);
+    context = xcalloc(1, sizeof *context);
     if (context == NULL)
 	return NULL;
 
-    memset(context, 0, sizeof *context);
     context->base.destroy           = __glXDRIcontextDestroy;
     context->base.makeCurrent       = __glXDRIcontextMakeCurrent;
     context->base.loseCurrent       = __glXDRIcontextLoseCurrent;
@@ -305,12 +304,10 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
 
     ScreenPtr pScreen = driScreen->base.pScreen;
 
-    private = xalloc(sizeof *private);
+    private = xcalloc(1, sizeof *private);
     if (private == NULL)
 	return NULL;
 
-    memset(private, 0, sizeof *private);
-
     private->screen = driScreen;
     if (!__glXDrawableInit(&private->base, screen,
 			   pDraw, type, drawId, glxConfig)) {
@@ -442,10 +439,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     const __DRIconfig **driConfigs;
     int i;
 
-    screen = xalloc(sizeof *screen);
+    screen = xcalloc(1, sizeof *screen);
     if (screen == NULL)
 	return NULL;
-    memset(screen, 0, sizeof *screen);
 
     screen->base.destroy        = __glXDRIscreenDestroy;
     screen->base.createContext  = __glXDRIscreenCreateContext;
diff --git a/hw/dmx/config/dmxparse.c b/hw/dmx/config/dmxparse.c
index 0bf9470..28a1835 100644
--- a/hw/dmx/config/dmxparse.c
+++ b/hw/dmx/config/dmxparse.c
@@ -65,12 +65,11 @@ void dmxConfigLog(const char *format, ...)
 
 void *dmxConfigAlloc(unsigned long bytes)
 {
-    void *area = malloc(bytes);
+    void *area = calloc(1, bytes);
     if (!area) {
         dmxConfigLog("dmxConfigAlloc: out of memory\n");
         return NULL;
     }
-    memset(area, 0, bytes);
     return area;
 }
 
@@ -249,8 +248,6 @@ DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
 {
     DMXConfigDisplayPtr pDisplay = dmxConfigAlloc(sizeof(*pDisplay));
 
-    memset(pDisplay, 0, sizeof(*pDisplay));
-
     pDisplay->start          = pStart;
     pDisplay->dname          = pName;
     pDisplay->dim            = pDim;
diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index 00200a8..05e5fab 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -341,16 +341,14 @@ do {									\
 #define _MAXSCREENSALLOCF(o,size,fatal)                                 \
     do {                                                                \
         if (!o) {                                                       \
-            o = xalloc((size) * sizeof(*(o)));                          \
-            if (o) memset(o, 0, (size) * sizeof(*(o)));                 \
+            o = xcalloc((size), sizeof(*(o)));                          \
             if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o);       \
         }                                                               \
     } while (0)
 #define _MAXSCREENSALLOCR(o,size,retval)                                \
     do {                                                                \
         if (!o) {                                                       \
-            o = xalloc((size) * sizeof(*(o)));                          \
-            if (o) memset(o, 0, (size) * sizeof(*(o)));                 \
+            o = xcalloc((size), sizeof(*(o)));                          \
             if (!o) return retval;                                      \
         }                                                               \
     } while (0)
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index aaa50d5..d20c844 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -1121,11 +1121,10 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
     }
 
     /* Now allocate the memory we need */
-    images = xalloc(len_images*sizeof(char));
+    images = xcalloc(len_images, sizeof(char));
     gids   = xalloc(glyphSet->hash.tableEntries*sizeof(Glyph));
     glyphs = xalloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
 
-    memset(images, 0, len_images * sizeof(char));
     pos = images;
     ctr = 0;
     
diff --git a/hw/dmx/dmxstat.c b/hw/dmx/dmxstat.c
index a89c69e..e3c13a6 100644
--- a/hw/dmx/dmxstat.c
+++ b/hw/dmx/dmxstat.c
@@ -115,8 +115,7 @@ void dmxStatActivate(const char *interval, const char *displays)
 /** Allocate a \a DMXStatInfo structure. */
 DMXStatInfo *dmxStatAlloc(void)
 {
-    DMXStatInfo *pt = malloc(sizeof(*pt));
-    memset(pt, 0, sizeof(*pt));
+    DMXStatInfo *pt = calloc(1, sizeof(*pt));
     return pt;
 }
 
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index a621542..536921a 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -146,11 +146,10 @@ static int CreateContext(__GLXclientState *cl,
     /*
     ** Allocate memory for the new context
     */
-    glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
+    glxc = __glXCalloc(1, sizeof(__GLXcontext));
     if (!glxc) {
 	return BadAlloc;
     }
-    memset(glxc, 0, sizeof(__GLXcontext));
 
     pScreen = screenInfo.screens[screen];
     pGlxScreen = &__glXActiveScreens[screen];
diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c
index 77dfeb2..3a24881 100644
--- a/hw/dmx/glxProxy/glxext.c
+++ b/hw/dmx/glxProxy/glxext.c
@@ -419,19 +419,17 @@ static int __glXDispatch(ClientPtr client)
     opcode = stuff->glxCode;
     cl = __glXClients[client->index];
     if (!cl) {
-	cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+	cl = __glXCalloc(1, sizeof(__GLXclientState));
 	 __glXClients[client->index] = cl;
 	if (!cl) {
 	    return BadAlloc;
 	}
-	memset(cl, 0, sizeof(__GLXclientState));
 
-	cl->be_displays = (Display **) __glXMalloc( screenInfo.numScreens * sizeof(Display *) );
+	cl->be_displays = __glXCalloc(screenInfo.numScreens, sizeof(Display *));
 	if (!cl->be_displays) {
 	    __glXFree( cl );
 	    return BadAlloc;
 	}
-	memset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
     }
     
     if (!cl->inUse) {
@@ -473,20 +471,17 @@ static int __glXSwapDispatch(ClientPtr client)
     opcode = stuff->glxCode;
     cl = __glXClients[client->index];
     if (!cl) {
-	cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+	cl = __glXCalloc(1, sizeof(__GLXclientState));
 	 __glXClients[client->index] = cl;
 	if (!cl) {
 	    return BadAlloc;
 	}
-	memset(cl, 0, sizeof(__GLXclientState));
 
-	cl->be_displays = (Display **) __glXMalloc( screenInfo.numScreens * sizeof(Display *) );
+	cl->be_displays = __glXCalloc(screenInfo.numScreens, sizeof(Display *));
 	if (!cl->be_displays) {
 	    __glXFree( cl );
 	    return BadAlloc;
 	}
-
-	memset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
     }
     
     if (!cl->inUse) {
diff --git a/hw/dmx/glxProxy/glxutil.c b/hw/dmx/glxProxy/glxutil.c
index a7aedbe..080992e 100644
--- a/hw/dmx/glxProxy/glxutil.c
+++ b/hw/dmx/glxProxy/glxutil.c
@@ -69,13 +69,11 @@ __glXCalloc(size_t numElements, size_t elementSize)
     if ((numElements == 0) || (elementSize == 0)) {
 	return NULL;
     }
-    size = numElements * elementSize;
-    addr = (void *) xalloc(size);
+    addr = xcalloc(numElements, elementSize);
     if (addr == NULL) {
 	/* XXX: handle out of memory error */
 	return NULL;
     }
-    memset(addr, 0, size);
     return addr;
 }
 
diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index b179109..14dc973 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -104,8 +104,7 @@ typedef struct _myPrivate {
 pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice)
 {
     GETDMXLOCALFROMPDEVICE;
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->dmxLocal  = dmxLocal;
     return priv;
 }
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index b2a2ec3..48c7034 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -140,8 +140,7 @@ static int unscaley(myPrivate *priv, int y)
 pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice)
 {
     GETDMXLOCALFROMPDEVICE;
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->dmxLocal  = dmxLocal;
     return priv;
 }
diff --git a/hw/dmx/input/dmxmotion.c b/hw/dmx/input/dmxmotion.c
index cc55eed..e7f5b59 100644
--- a/hw/dmx/input/dmxmotion.c
+++ b/hw/dmx/input/dmxmotion.c
@@ -113,8 +113,7 @@ void dmxPointerPutMotionEvent(DeviceIntPtr pDevice,
                                      * DMX_MOTION_SIZE);
         dmxLocal->head      = 0;
         dmxLocal->tail      = 0;
-        dmxLocal->valuators = xalloc(sizeof(*dmxLocal->valuators) * numAxes);
-        memset(dmxLocal->valuators, 0, sizeof(*dmxLocal->valuators) * numAxes);
+        dmxLocal->valuators = xcalloc(sizeof(*dmxLocal->valuators), numAxes);
     } else {
         if (++dmxLocal->tail >= DMX_MOTION_SIZE) dmxLocal->tail = 0;
         if (dmxLocal->head == dmxLocal->tail)
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 42a807b..c5dada9 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -358,8 +358,7 @@ static unsigned char at2lnx[NUM_KEYCODES] =
 /** Create a private structure for use within this file. */
 pointer kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard)
 {
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->fd        = -1;
     priv->pKeyboard = pKeyboard;
     return priv;
diff --git a/hw/dmx/input/lnx-ms.c b/hw/dmx/input/lnx-ms.c
index b3692a0..705d3f4 100644
--- a/hw/dmx/input/lnx-ms.c
+++ b/hw/dmx/input/lnx-ms.c
@@ -292,8 +292,7 @@ void msLinuxVTPostSwitch(pointer p)
 /** Create a private structure for use within this file. */
 pointer msLinuxCreatePrivate(DeviceIntPtr pMouse)
 {
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->fd     = -1;
     priv->pMouse = pMouse;
     return priv;
diff --git a/hw/dmx/input/lnx-ps2.c b/hw/dmx/input/lnx-ps2.c
index 8b906df..78debed 100644
--- a/hw/dmx/input/lnx-ps2.c
+++ b/hw/dmx/input/lnx-ps2.c
@@ -260,8 +260,7 @@ void ps2LinuxVTPostSwitch(pointer p)
 /** Create a private structure for use within this file. */
 pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse)
 {
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->fd     = -1;
     priv->pMouse = pMouse;
     return priv;
diff --git a/hw/dmx/input/usb-common.c b/hw/dmx/input/usb-common.c
index 70695d0..7b4f632 100644
--- a/hw/dmx/input/usb-common.c
+++ b/hw/dmx/input/usb-common.c
@@ -368,8 +368,7 @@ void usbOff(DevicePtr pDev)
 /** Create a private structure for use within this file. */
 pointer usbCreatePrivate(DeviceIntPtr pDevice)
 {
-    myPrivate *priv = xalloc(sizeof(*priv));
-    memset(priv, 0, sizeof(*priv));
+    myPrivate *priv = xcalloc(1, sizeof(*priv));
     priv->fd        = -1;
     priv->pDevice   = pDevice;
     return priv;
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 408144e..ab8459c 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -185,12 +185,11 @@ ephyrScreenInit (KdScreenInfo *screen)
 {
   EphyrScrPriv *scrpriv;
   
-  scrpriv = xalloc (sizeof (EphyrScrPriv));
+  scrpriv = xcalloc (1, sizeof (EphyrScrPriv));
 
   if (!scrpriv)
     return FALSE;
 
-  memset (scrpriv, 0, sizeof (EphyrScrPriv));
   screen->driver = scrpriv;
 
   if (!ephyrScreenInitialize (screen, scrpriv))
diff --git a/hw/kdrive/fake/fake.c b/hw/kdrive/fake/fake.c
index d77c4f1..ff59798 100644
--- a/hw/kdrive/fake/fake.c
+++ b/hw/kdrive/fake/fake.c
@@ -121,10 +121,9 @@ fakeScreenInit (KdScreenInfo *screen)
 {
     FakeScrPriv *scrpriv;
 
-    scrpriv = xalloc (sizeof (FakeScrPriv));
+    scrpriv = xcalloc (1, sizeof (FakeScrPriv));
     if (!scrpriv)
 	return FALSE;
-    memset (scrpriv, '\0', sizeof (FakeScrPriv));
     screen->driver = scrpriv;
     if (!fakeScreenInitialize (screen, scrpriv))
     {
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 35ca4de..04f697b 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -297,10 +297,9 @@ fbdevScreenInit (KdScreenInfo *screen)
 {
     FbdevScrPriv *scrpriv;
 
-    scrpriv = xalloc (sizeof (FbdevScrPriv));
+    scrpriv = xcalloc (1, sizeof (FbdevScrPriv));
     if (!scrpriv)
 	return FALSE;
-    memset (scrpriv, '\0', sizeof (FbdevScrPriv));
     screen->driver = scrpriv;
     if (!fbdevScreenInitialize (screen, scrpriv))
     {
diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
index 2eaa1e3..4ccd822 100644
--- a/hw/kdrive/linux/evdev.c
+++ b/hw/kdrive/linux/evdev.c
@@ -251,13 +251,12 @@ EvdevPtrEnable (KdPointerInfo *pi)
         close (fd);
         return BadMatch;
     }
-    ke = xalloc (sizeof (Kevdev));
+    ke = xcalloc (1, sizeof (Kevdev));
     if (!ke)
     {
         close (fd);
         return BadAlloc;
     }
-    memset (ke, '\0', sizeof (Kevdev));
     if (ISBITSET (ev, EV_KEY))
     {
         if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
@@ -440,12 +439,11 @@ EvdevKbdEnable (KdKeyboardInfo *ki)
         return BadMatch;
     }
 
-    ke = xalloc (sizeof (Kevdev));
+    ke = xcalloc (1, sizeof (Kevdev));
     if (!ke) {
         close (fd);
         return BadAlloc;
     }
-    memset (ke, '\0', sizeof (Kevdev));
 
     if (!KdRegisterFd (fd, EvdevKbdRead, ki)) {
         xfree (ke);
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 1478a94..d93e343 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -739,10 +739,9 @@ KdAllocatePrivates (ScreenPtr pScreen)
     if (kdGeneration != serverGeneration)
 	kdGeneration = serverGeneration;
 
-    pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv));
+    pScreenPriv = xcalloc(1, sizeof (*pScreenPriv));
     if (!pScreenPriv)
 	return FALSE;
-    memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec));
     KdSetScreenPriv (pScreen, pScreenPriv);
     return TRUE;
 }
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index 316b873..b7cc8f1 100644
--- a/hw/kdrive/vesa/vesa.c
+++ b/hw/kdrive/vesa/vesa.c
@@ -175,10 +175,8 @@ vesaGetModes (Vm86InfoPtr vi, int *ret_nmode)
     if (nmode <= 0)
 	return 0;
     
-    modes = xalloc (nmode * sizeof (VesaModeRec));
-    
-    memset (modes, '\0', nmode * sizeof (VesaModeRec));
-    
+    modes = xcalloc (nmode, sizeof (VesaModeRec));
+ 
     if (nmodeVga)
     {
 	code = VgaGetModes (vi, modes, nmodeVga);
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 5f96711..793ecfa 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -295,11 +295,10 @@ autoConfigDevice(GDevPtr preconf_device)
     if (preconf_device) {
         ptr = preconf_device;
     } else {
-        ptr = (GDevPtr)xalloc(sizeof(GDevRec));
+        ptr = xcalloc(1, sizeof(GDevRec));
         if (!ptr) {
             return NULL;
         }
-        memset((GDevPtr)ptr, 0, sizeof(GDevRec));
         ptr->chipID = -1;
         ptr->chipRev = -1;
         ptr->irq = -1;
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 119a0a8..d61f59e 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -287,8 +287,7 @@ configureInputSection (void)
 #endif
     }
 
-    mouse = xf86confmalloc(sizeof(XF86ConfInputRec));
-    memset((XF86ConfInputPtr)mouse,0,sizeof(XF86ConfInputRec));
+    mouse = xf86confcalloc(1, sizeof(XF86ConfInputRec));
     mouse->inp_identifier = "Mouse0";
     mouse->inp_driver = "mouse";
     mouse->inp_option_lst = 
@@ -324,8 +323,7 @@ configureScreenSection (int screennum)
     {
 	XF86ConfDisplayPtr display;
 
-	display = xf86confmalloc(sizeof(XF86ConfDisplayRec));
-    	memset((XF86ConfDisplayPtr)display,0,sizeof(XF86ConfDisplayRec));
+	display = xf86confcalloc(1, sizeof(XF86ConfDisplayRec));
 	display->disp_depth = depths[i];
 	display->disp_black.red = display->disp_white.red = -1;
 	display->disp_black.green = display->disp_white.green = -1;
@@ -526,8 +524,7 @@ configureModuleSection (void)
 	for (el = elist; *el; el++) {
 	    XF86LoadPtr module;
 
-    	    module = xf86confmalloc(sizeof(XF86LoadRec));
-    	    memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+    	    module = xf86confcalloc(1, sizeof(XF86LoadRec));
     	    module->load_name = *el;
             ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
                                 (glp)ptr->mod_load_lst, (glp)module);
@@ -541,8 +538,7 @@ configureModuleSection (void)
 	for (el = elist; *el; el++) {
 	    XF86LoadPtr module;
 
-    	    module = xf86confmalloc(sizeof(XF86LoadRec));
-    	    memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+    	    module = xf86confcalloc(sizeof(XF86LoadRec));
     	    module->load_name = *el;
 
             /* Add only those font backends which are referenced by fontpath */
@@ -716,11 +712,7 @@ DoConfigure()
     xf86FindPrimaryDevice();
  
     /* Create XF86Config file structure */
-    xf86config = malloc(sizeof(XF86ConfigRec));
-    memset ((XF86ConfigPtr)xf86config, 0, sizeof(XF86ConfigRec));
-    xf86config->conf_device_lst = NULL;
-    xf86config->conf_screen_lst = NULL;
-    xf86config->conf_monitor_lst = NULL;
+    xf86config = calloc(1, sizeof(XF86ConfigRec));
 
     /* Call all of the probe functions, reporting the results. */
     for (CurrentDriver = 0;  CurrentDriver < xf86NumDrivers;  CurrentDriver++) {
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index b263f9b..02d6e37 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -964,9 +964,8 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
    }
 
    if(!winPriv) {
-	winPriv = xalloc(sizeof(XF86XVWindowRec));
+	winPriv = xcalloc(1, sizeof(XF86XVWindowRec));
 	if(!winPriv) return BadAlloc;
-	memset(winPriv, 0, sizeof(XF86XVWindowRec));
 	winPriv->PortRec = portPriv;
 	winPriv->next = PrivRoot;
 	dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
@@ -1175,7 +1174,7 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen)
   int c;
 
   /* Clear offscreen images */
-  (void)memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0]));
+  memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0]));
 
   if(!ScreenPriv) return TRUE;
 
diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index a30dee1..d04d0a2 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -176,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
      * have executable code there.  Note that xf86ReadBIOS() can only read in
      * 64kB at a time.
      */
-    (void)memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS);
+    memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS);
 #if 0
     for (cs = V_BIOS;  cs < SYS_BIOS;  cs += V_BIOS_SIZE)
 	if (xf86ReadBIOS(cs, 0, (unsigned char *)base + cs, V_BIOS_SIZE) <
@@ -223,7 +223,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
 	case BUS_ISA:
 	    vbiosMem = (unsigned char *)sysMem + bios_location;
 #if 0
-	    (void)memset(vbiosMem, 0, V_BIOS_SIZE);
+	    memset(vbiosMem, 0, V_BIOS_SIZE);
 	    if (xf86ReadBIOS(bios_location, 0, vbiosMem, V_BIOS_SIZE)
 		< V_BIOS_SIZE)
 		xf86DrvMsg(screen, X_WARNING,
@@ -255,7 +255,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
      * 128KiB.
      */
     vbiosMem = (char *)base + V_BIOS;
-    (void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
+    memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
     if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
 	xf86DrvMsg(screen, X_WARNING,
 		   "Unable to retrieve all of segment 0x0C0000.\n");
diff --git a/hw/xfree86/os-support/bsd/libusb/parse.c b/hw/xfree86/os-support/bsd/libusb/parse.c
index 0a846e4..ab33bbe 100644
--- a/hw/xfree86/os-support/bsd/libusb/parse.c
+++ b/hw/xfree86/os-support/bsd/libusb/parse.c
@@ -80,8 +80,7 @@ hid_start_parse(report_desc_t d, int kindset)
 
 	_DIAGASSERT(d != NULL);
 
-	s = malloc(sizeof *s);
-	memset(s, 0, sizeof *s);
+	s = calloc(1, sizeof *s);
 	s->start = s->p = d->data;
 	s->end = d->data + d->size;
 	s->kindset = kindset;
diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c
index ff257a8..8763d0e 100644
--- a/hw/xfree86/os-support/bus/Sbus.c
+++ b/hw/xfree86/os-support/bus/Sbus.c
@@ -321,7 +321,7 @@ sparcPromAssignNodes(void)
     FILE *f;
     sbusDevicePtr devicePtrs[32];
 
-    (void)memset(devicePtrs, 0, sizeof(devicePtrs));
+    memset(devicePtrs, 0, sizeof(devicePtrs));
     for (psdpp = xf86SbusInfo, n = 0; (psdp = *psdpp); psdpp++, n++) {
 	if (psdp->fbNum != n)
 	    holes = 1;
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 4a48632..8b0a820 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -106,7 +106,7 @@ linuxPciInit(void)
     struct stat st;
 
 #ifndef INCLUDE_XF86_NO_DOMAIN
-    (void) memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
+    memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
 #endif
 
     if (-1 == stat("/proc/bus/pci", &st)) {
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 9e2c619..67eb161 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -245,7 +245,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
      * 64K bytes at a time.
      */
     if (!videoBiosMapped) {
-	(void)memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
+	memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
 #ifdef DEBUG
 	ErrorF("Reading BIOS\n");
 #endif
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 829963a..b79814d 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -244,8 +244,8 @@ xf86CloseConsole(void)
 			    "xf86CloseConsole():  unable to mmap framebuffer"
 			    " (%s)\n", strerror(errno));
 		} else {
-		    (void)memset(fbdata, 0, fbattr.fbtype.fb_size);
-		    (void)munmap(fbdata, fbattr.fbtype.fb_size);
+		    memset(fbdata, 0, fbattr.fbtype.fb_size);
+		    munmap(fbdata, fbattr.fbtype.fb_size);
 		}
 	    }
 
diff --git a/hw/xfree86/parser/Configint.h b/hw/xfree86/parser/Configint.h
index 684a001..815c1a3 100644
--- a/hw/xfree86/parser/Configint.h
+++ b/hw/xfree86/parser/Configint.h
@@ -100,12 +100,10 @@ LexRec, *LexPtr;
 #define TestFree(a) if (a) { xf86conffree (a); a = NULL; }
 
 #define parsePrologue(typeptr,typerec) typeptr ptr; \
-if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return NULL; } \
-memset(ptr,0,sizeof(typerec));
+if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return NULL; }
 
 #define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
-if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return; } \
-memset(ptr,0,sizeof(typerec));
+if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return; }
 
 #define HANDLE_RETURN(f,func)\
 if ((ptr->f=func) == NULL)\
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 430da0a..b044a6a 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -100,7 +100,6 @@ xf86readConfigFile (void)
 	{
 		return NULL;
 	}
-	memset (ptr, 0, sizeof (XF86ConfigRec));
 
 	while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
 	{
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index ea05233..4374e51 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -255,7 +255,7 @@ RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
 	    DstM = (SCANLINE*)mem;
 	    if (!(infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK))
 		DstM += words;
-	    (void)memset(DstM, -1, words * sizeof(SCANLINE));
+	    memset(DstM, -1, words * sizeof(SCANLINE));
 	}
 	return mem;
     }
diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index eccc6d5..ed22047 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -171,11 +171,9 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
   
   GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
 
-  context = malloc (sizeof (__GLXAquaContext));
+  context = calloc (1, sizeof (__GLXAquaContext));
   if (context == NULL) return NULL;
 
-  memset(context, 0, sizeof *context);
-
   context->base.pGlxScreen = screen;
   context->base.config      = config;
 
@@ -1099,8 +1097,7 @@ static void init_screen_visuals(__GLXAquaScreen *screen) {
      * FIXME: malloc / free.  If nothing else, convert 'used' to
      * FIXME: array of bytes instead of ints!
      */
-    used = (int *)malloc(pScreen->numVisuals * sizeof(int));
-    memset(used, 0, pScreen->numVisuals * sizeof(int));
+    used = calloc(pScreen->numVisuals, sizeof(int));
 
     i = 0;
     for ( modes = screen -> base.visuals
@@ -1184,11 +1181,9 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen,
 
   GLAQUA_DEBUG_MSG("glAquaScreenCreateDrawable(%p,%p,%d,%p)\n", context, pDraw, drawId, modes);
 
-  glxPriv = xalloc(sizeof *glxPriv);
+  glxPriv = calloc(1, sizeof *glxPriv);
   if (glxPriv == NULL) return NULL;
 
-  memset(glxPriv, 0, sizeof *glxPriv);
-
   if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, GLX_DRAWABLE_PIXMAP /*?*/, drawId, modes)) {
     xfree(glxPriv);
     return NULL;
diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c
index 021b8b8..92775e4 100644
--- a/hw/xwin/wincursor.c
+++ b/hw/xwin/wincursor.c
@@ -204,8 +204,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
   /* Allocate memory for the bitmaps */
   pAnd = malloc (nBytes);
   memset (pAnd, 0xFF, nBytes);
-  pXor = malloc (nBytes);
-  memset (pXor, 0x00, nBytes);
+  pXor = calloc (1, nBytes);
 
   /* Convert the X11 bitmap to a win32 bitmap 
    * The first is for an empty mask */
diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 45ed093..fbc516c 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -302,12 +302,10 @@ winXIconToHICON (WindowPtr pWin, int iconSize)
   /* Mask is 1-bit deep */
   maskStride = ((iconSize * 1 + 31) & (~31)) / 8; 
 
-  image = (unsigned char * ) malloc (stride * iconSize);
-  imageMask = (unsigned char *) malloc (stride * iconSize);
-  mask = (unsigned char *) malloc (maskStride * iconSize);
-  
+  image = malloc (stride * iconSize);
+  imageMask = malloc (stride * iconSize);
   /* Default to a completely black mask */
-  memset (mask, 0, maskStride * iconSize);
+  mask = calloc (maskStride, iconSize);
   
   winScaleXBitmapToWindows (iconSize, effBPP, iconPtr, image);
   maskPtr = (PixmapPtr) LookupIDByType (hints.icon_mask, RT_PIXMAP);
diff --git a/render/glyph.c b/render/glyph.c
index ae04f60..87b332e 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -441,10 +441,9 @@ bail:
 Bool
 AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
 {
-    hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec));
+    hash->table = xcalloc (hashSet->size, sizeof (GlyphRefRec));
     if (!hash->table)
 	return FALSE;
-    memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec));
     hash->hashSet = hashSet;
     hash->tableEntries = 0;
     return TRUE;
diff --git a/render/picture.c b/render/picture.c
index 9def47b..fc2bf43 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -316,10 +316,9 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
     }
     
 
-    pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
+    pFormats = xcalloc (nformats, sizeof (PictFormatRec));
     if (!pFormats)
 	return 0;
-    memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
     for (f = 0; f < nformats; f++)
     {
         pFormats[f].id = FakeClientID (0);
commit 0b7b89fbac0b3865b2cf51295c68a5f4c7523f28
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Oct 6 14:19:30 2008 -0400

    xalloc+bzero -> xcalloc

diff --git a/Xi/exevents.c b/Xi/exevents.c
index d59a87d..6f65279 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1516,12 +1516,11 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
 
     if (!pWin->optional && !MakeWindowOptional(pWin))
 	return BadAlloc;
-    others = (InputClients *) xalloc(sizeof(InputClients));
+    others = xcalloc(1, sizeof(InputClients));
     if (!others)
 	return BadAlloc;
     if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
 	return BadAlloc;
-    bzero((char *)&others->mask[0], sizeof(Mask) * EMASKSIZE);
     others->mask[mskidx] = mask;
     others->resource = FakeClientID(client->index);
     others->next = pWin->optional->inputMasks->inputClients;
@@ -1536,11 +1535,9 @@ MakeInputMasks(WindowPtr pWin)
 {
     struct _OtherInputMasks *imasks;
 
-    imasks = (struct _OtherInputMasks *)
-	xalloc(sizeof(struct _OtherInputMasks));
+    imasks = xcalloc(1, sizeof(struct _OtherInputMasks));
     if (!imasks)
 	return FALSE;
-    bzero((char *)imasks, sizeof(struct _OtherInputMasks));
     pWin->optional->inputMasks = imasks;
     return TRUE;
 }
diff --git a/dbe/dbe.c b/dbe/dbe.c
index 1a08bda..bd27789 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -297,10 +297,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
          * Allocate a window priv.
          */
 
-        pDbeWindowPriv = (DbeWindowPrivPtr)xalloc(sizeof(DbeWindowPrivRec));
+        pDbeWindowPriv = xcalloc(1, sizeof(DbeWindowPrivRec));
 	if (!pDbeWindowPriv)
             return(BadAlloc);
-	bzero(pDbeWindowPriv, sizeof(DbeWindowPrivRec));
 
         /* Fill out window priv information. */
         pDbeWindowPriv->pWindow      = pWin;
diff --git a/dix/devices.c b/dix/devices.c
index adb012f..5e0b68f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -495,13 +495,12 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what)
             return BadAlloc;
         }
 
-        modMap = (CARD8 *)xalloc(MAP_LENGTH);
+        modMap = xcalloc(1, MAP_LENGTH);
         if (!modMap) {
             ErrorF("[dix] Couldn't allocate core modifier map\n");
             xfree(classes);
             return BadAlloc;
         }
-        bzero((char *)modMap, MAP_LENGTH);
 
 #ifdef XKB
         if (!noXkbExtension) {
@@ -1141,10 +1140,9 @@ InitModMap(KeyClassPtr keyc)
 	    }
 	}
     }
-    keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
+    keyc->modifierKeyMap = xcalloc(8, keyc->maxKeysPerModifier);
     if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
 	return (FALSE);
-    bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
     for (i = 0; i < 8; i++)
 	keysPerModifier[i] = 0;
     for (i = 8; i < MAP_LENGTH; i++)
@@ -1168,24 +1166,13 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers
     int i;
     KeyClassPtr keyc;
 
-    keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec));
+    keyc = xcalloc(1, sizeof(KeyClassRec));
     if (!keyc)
 	return FALSE;
-    keyc->curKeySyms.map = (KeySym *)NULL;
-    keyc->curKeySyms.mapWidth = 0;
     keyc->curKeySyms.minKeyCode = pKeySyms->minKeyCode;
     keyc->curKeySyms.maxKeyCode = pKeySyms->maxKeyCode;
-    keyc->modifierKeyMap = (KeyCode *)NULL;
-    keyc->state = 0;
-    keyc->prev_state = 0;
     if (pModifiers)
 	memmove((char *)keyc->modifierMap, (char *)pModifiers, MAP_LENGTH);
-    else
-	bzero((char *)keyc->modifierMap, MAP_LENGTH);
-    bzero((char *)keyc->down, DOWN_LENGTH);
-    bzero((char *)keyc->postdown, DOWN_LENGTH);
-    for (i = 0; i < 8; i++)
-	keyc->modifierKeyCount[i] = 0;
     if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc))
     {
 	xfree(keyc->curKeySyms.map);
@@ -1208,19 +1195,12 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons,
     ButtonClassPtr butc;
     int i;
 
-    butc = (ButtonClassPtr)xalloc(sizeof(ButtonClassRec));
+    butc = xcalloc(1, sizeof(ButtonClassRec));
     if (!butc)
 	return FALSE;
     butc->numButtons = numButtons;
     for (i = 1; i <= numButtons; i++)
 	butc->map[i] = map[i];
-    butc->buttonsDown = 0;
-    butc->state = 0;
-    butc->motionMask = 0;
-    bzero((char *)butc->down, sizeof(butc->down));
-#ifdef XKB
-    butc->xkb_acts=	NULL;
-#endif
     dev->button = butc;
     return TRUE;
 }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 64cde49..d14f8dc 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2875,18 +2875,16 @@ ProcCreateCursor (ClientPtr client)
 	return (BadMatch);
 
     n = BitmapBytePad(width)*height;
-    srcbits = (unsigned char *)xalloc(n);
+    srcbits = xcalloc(1, n);
     if (!srcbits)
 	return (BadAlloc);
-    mskbits = (unsigned char *)xalloc(n);
+    mskbits = xalloc(n);
     if (!mskbits)
     {
 	xfree(srcbits);
 	return (BadAlloc);
     }
 
-    /* zeroing the (pad) bits helps some ddx cursor handling */
-    bzero((char *)srcbits, n);
     (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
 					 XYPixmap, 1, (pointer)srcbits);
     if ( msk == (PixmapPtr)NULL)
diff --git a/dix/glyphcurs.c b/dix/glyphcurs.c
index 905b5fb..f74b137 100644
--- a/dix/glyphcurs.c
+++ b/dix/glyphcurs.c
@@ -91,11 +91,9 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, unsigned cha
 
     pScreen = screenInfo.screens[0];
     nby = BitmapBytePad(cm->width) * (long)cm->height;
-    pbits = (char *)xalloc(nby);
+    pbits = xcalloc(1, nby);
     if (!pbits)
 	return BadAlloc;
-    /* zeroing the (pad) bits seems to help some ddx cursor handling */
-    bzero(pbits, nby);
 
     ppix = (PixmapPtr)(*pScreen->CreatePixmap)(pScreen, cm->width,
 					       cm->height, 1,
diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c
index 2621f10..d592e68 100644
--- a/hw/kdrive/src/kinfo.c
+++ b/hw/kdrive/src/kinfo.c
@@ -34,10 +34,9 @@ KdCardInfoAdd (KdCardFuncs  *funcs,
 {
     KdCardInfo	*ci, **prev;
 
-    ci = (KdCardInfo *) xalloc (sizeof (KdCardInfo));
+    ci = xcalloc (1, sizeof (KdCardInfo));
     if (!ci)
 	return 0;
-    bzero (ci, sizeof (KdCardInfo));
     for (prev = &kdCardInfo; *prev; prev = &(*prev)->next);
     *prev = ci;
     ci->cfuncs = funcs;
@@ -80,10 +79,9 @@ KdScreenInfoAdd (KdCardInfo *ci)
     KdScreenInfo    *si, **prev;
     int		    n;
 
-    si = (KdScreenInfo *) xalloc (sizeof (KdScreenInfo));
+    si = xcalloc (1, sizeof (KdScreenInfo));
     if (!si)
 	return 0;
-    bzero (si, sizeof (KdScreenInfo));
     for (prev = &ci->screenList, n = 0; *prev; prev = &(*prev)->next, n++);
     *prev = si;
     si->next = 0;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index e200c54..b44218d 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1127,12 +1127,10 @@ KdGetOptions (InputOption **options, char *string)
     InputOption     *newopt = NULL, **tmpo = NULL;
     int             tam_key = 0;
 
-    newopt = (InputOption *) xalloc(sizeof (InputOption));
+    newopt = xcalloc(1, sizeof (InputOption));
     if (!newopt)
         return FALSE;
 
-    bzero(newopt, sizeof (InputOption));
-
     for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
         ; /* Hello, I'm here */ 
     *tmpo = newopt;
diff --git a/hw/xfree86/xaa/xaaCpyPlane.c b/hw/xfree86/xaa/xaaCpyPlane.c
index a0ebb75..aa4c040 100644
--- a/hw/xfree86/xaa/xaaCpyPlane.c
+++ b/hw/xfree86/xaa/xaaCpyPlane.c
@@ -131,11 +131,9 @@ XAACopyPlaneNtoNColorExpand(
 	h = height = pbox->y2 - pbox->y1;
 	pitch = BitmapBytePad(width);
 
-	if(!(data = xalloc(height * pitch)))
+	if(!(data = xcalloc(height, pitch)))
 	   goto ALLOC_FAILED;
 
-        bzero(data, height * pitch);
-
 	dataPtr = data;
         srcPtr = ((pptSrc->y) * srcwidth) + src + 
                         ((pptSrc->x) * Bpp) + offset;
diff --git a/hw/xfree86/xaa/xaaNonTEText.c b/hw/xfree86/xaa/xaaNonTEText.c
index d4661e8..d32c0bb 100644
--- a/hw/xfree86/xaa/xaaNonTEText.c
+++ b/hw/xfree86/xaa/xaaNonTEText.c
@@ -291,8 +291,7 @@ PolyGlyphBltAsSingleBitmap (
 
     pitch = (Right - Left + 31) >> 5;
     size = (pitch << 2) * (Bottom - Top);
-    block = (CARD32*)xalloc(size);
-    bzero(block, size);
+    block = xcalloc(1, size);
 
     topLine = 10000; botLine = -10000;
 
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 99375b6..3e82a55 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -317,11 +317,10 @@ miGetPlane(
     sy += pDraw->y;
     widthInBytes = BitmapBytePad(w);
     if(!result)
-        result = (MiBits *)xalloc(h * widthInBytes);
+        result = xcalloc(h, widthInBytes);
     if (!result)
 	return (MiBits *)NULL;
     bitsPerPixel = pDraw->bitsPerPixel;
-    bzero((char *)result, h * widthInBytes);
     pOut = (OUT_TYPE *) result;
     if(bitsPerPixel == 1)
     {
diff --git a/render/glyph.c b/render/glyph.c
index 849e65f..ae04f60 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -513,10 +513,9 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
     }
 
     size = sizeof (GlyphSetRec);
-    glyphSet = xalloc (size);
+    glyphSet = xcalloc (1, size);
     if (!glyphSet)
 	return FALSE;
-    bzero((char *)glyphSet, size);
 
     if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
     {
diff --git a/render/render.c b/render/render.c
index 1b7d78b..9e04a13 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1571,21 +1571,19 @@ ProcRenderCreateCursor (ClientPtr client)
     
     stride = BitmapBytePad(width);
     nbytes_mono = stride*height;
-    srcbits = (unsigned char *)xalloc(nbytes_mono);
+    srcbits = xcalloc(nbytes_mono);
     if (!srcbits)
     {
 	xfree (argbbits);
 	return (BadAlloc);
     }
-    mskbits = (unsigned char *)xalloc(nbytes_mono);
+    mskbits = xcalloc(nbytes_mono);
     if (!mskbits)
     {
 	xfree(argbbits);
 	xfree(srcbits);
 	return (BadAlloc);
     }
-    bzero ((char *) mskbits, nbytes_mono);
-    bzero ((char *) srcbits, nbytes_mono);
 
     if (pSrc->format == PICT_a8r8g8b8)
     {


More information about the xorg-commit mailing list