summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-10-06 15:36:51 -0400
committerAdam Jackson <ajax@redhat.com>2008-10-06 15:36:51 -0400
commit8a5b89e8e184f4cbf33c6dee0b06e61d8f857576 (patch)
treeb042833775d237a3971eae7a7192400e064ad50d
parent0b7b89fbac0b3865b2cf51295c68a5f4c7523f28 (diff)
xalloc+memset(0) -> xcalloc
-rw-r--r--Xext/xres.c4
-rw-r--r--dix/devices.c46
-rw-r--r--glx/glxcmds.c3
-rw-r--r--glx/glxdri.c10
-rw-r--r--glx/glxdri2.c10
-rw-r--r--glx/glxdriswrast.c10
-rw-r--r--hw/dmx/config/dmxparse.c5
-rw-r--r--hw/dmx/dmx.h6
-rw-r--r--hw/dmx/dmxextension.c3
-rw-r--r--hw/dmx/dmxstat.c3
-rw-r--r--hw/dmx/glxProxy/glxcmds.c3
-rw-r--r--hw/dmx/glxProxy/glxext.c13
-rw-r--r--hw/dmx/glxProxy/glxutil.c4
-rw-r--r--hw/dmx/input/dmxbackend.c3
-rw-r--r--hw/dmx/input/dmxconsole.c3
-rw-r--r--hw/dmx/input/dmxmotion.c3
-rw-r--r--hw/dmx/input/lnx-keyboard.c3
-rw-r--r--hw/dmx/input/lnx-ms.c3
-rw-r--r--hw/dmx/input/lnx-ps2.c3
-rw-r--r--hw/dmx/input/usb-common.c3
-rw-r--r--hw/kdrive/ephyr/ephyr.c3
-rw-r--r--hw/kdrive/fake/fake.c3
-rw-r--r--hw/kdrive/fbdev/fbdev.c3
-rw-r--r--hw/kdrive/linux/evdev.c6
-rw-r--r--hw/kdrive/src/kdrive.c3
-rw-r--r--hw/kdrive/vesa/vesa.c6
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c3
-rw-r--r--hw/xfree86/common/xf86Configure.c18
-rw-r--r--hw/xfree86/common/xf86xv.c5
-rw-r--r--hw/xfree86/int10/generic.c6
-rw-r--r--hw/xfree86/os-support/bsd/libusb/parse.c3
-rw-r--r--hw/xfree86/os-support/bus/Sbus.c2
-rw-r--r--hw/xfree86/os-support/bus/linuxPci.c2
-rw-r--r--hw/xfree86/os-support/linux/int10/linux.c2
-rw-r--r--hw/xfree86/os-support/solaris/sun_init.c4
-rw-r--r--hw/xfree86/parser/Configint.h6
-rw-r--r--hw/xfree86/parser/read.c1
-rw-r--r--hw/xfree86/ramdac/xf86HWCurs.c2
-rw-r--r--hw/xquartz/GL/indirect.c11
-rw-r--r--hw/xwin/wincursor.c3
-rw-r--r--hw/xwin/winmultiwindowicons.c8
-rw-r--r--render/glyph.c3
-rw-r--r--render/picture.c3
43 files changed, 68 insertions, 179 deletions
diff --git a/Xext/xres.c b/Xext/xres.c
index 75ade58a1..bdc534c91 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 5e0b68f3c..9d4ce3462 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 6e7637ebe..ab2d91b1b 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 c33b5bd9b..ce098e1e6 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 495de8197..65138cd0f 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 28597044f..b42501280 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 0bf947051..28a1835af 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 00200a851..05e5fabd1 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 aaa50d5c4..d20c844aa 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 a89c69eae..e3c13a623 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 a621542ca..536921a87 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 77dfeb205..3a2488132 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 a7aedbedc..080992ea9 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 b1791098a..14dc97336 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 b2a2ec302..48c7034cb 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 cc55eedff..e7f5b5919 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 42a807b11..c5dada911 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 b3692a071..705d3f4ac 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 8b906df5f..78debed18 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 70695d0f1..7b4f632dc 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 408144e61..ab8459cfc 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 d77c4f106..ff597981d 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 35ca4dec6..04f697b9e 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 2eaa1e332..4ccd82239 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 1478a944d..d93e343e5 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 316b873ab..b7cc8f1e9 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 5f9671145..793ecfa85 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 119a0a8e3..d61f59ea8 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 b263f9bd3..02d6e37a4 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 a30dee103..d04d0a25e 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 0a846e42b..ab33bbe11 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 ff257a8c7..8763d0ece 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 4a48632f7..8b0a820fa 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 9e2c6199c..67eb16107 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 829963ab2..b79814d8a 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 684a001fc..815c1a376 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 430da0a5a..b044a6af8 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 ea0523362..4374e51d4 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 eccc6d5af..ed2204756 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 021b8b82c..92775e404 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 45ed093ec..fbc516cde 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 ae04f6029..87b332e2a 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 9def47b0f..fc2bf43d5 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);