xalloc+memset(0) -> xcalloc
This commit is contained in:
parent
0b7b89fbac
commit
8a5b89e8e1
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
10
glx/glxdri.c
10
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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)\
|
||||
|
|
|
@ -100,7 +100,6 @@ xf86readConfigFile (void)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
memset (ptr, 0, sizeof (XF86ConfigRec));
|
||||
|
||||
while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue