dix: use calloc() instead of malloc()
Using calloc() instead of malloc() as preventive measure, so there never can be any hidden bugs or leaks due uninitialized memory. The extra cost of using this compiler intrinsic should be practically impossible to measure - in many cases a good compiler can even deduce if certain areas really don't need to be zero'd (because they're written to right after allocation) and create more efficient machine code. The code pathes in question are pretty cold anyways, so it's probably not worth even thinking about potential extra runtime costs. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
a2d9d2078f
commit
0127d6ef13
|
@ -101,9 +101,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (makeit) {
|
if (makeit) {
|
||||||
NodePtr nd;
|
NodePtr nd = calloc(1, sizeof(NodeRec));
|
||||||
|
|
||||||
nd = malloc(sizeof(NodeRec));
|
|
||||||
if (!nd)
|
if (!nd)
|
||||||
return BAD_RESOURCE;
|
return BAD_RESOURCE;
|
||||||
if (lastAtom < XA_LAST_PREDEFINED) {
|
if (lastAtom < XA_LAST_PREDEFINED) {
|
||||||
|
|
|
@ -262,7 +262,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
sizebytes *= 3;
|
sizebytes *= 3;
|
||||||
sizebytes += sizeof(ColormapRec);
|
sizebytes += sizeof(ColormapRec);
|
||||||
if (mid == pScreen->defColormap) {
|
if (mid == pScreen->defColormap) {
|
||||||
pmap = malloc(sizebytes);
|
pmap = calloc(1, sizebytes);
|
||||||
if (!pmap)
|
if (!pmap)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
if (!dixAllocatePrivates(&pmap->devPrivates, PRIVATE_COLORMAP)) {
|
if (!dixAllocatePrivates(&pmap->devPrivates, PRIVATE_COLORMAP)) {
|
||||||
|
@ -1083,9 +1083,7 @@ AllocColor(ColormapPtr pmap,
|
||||||
* should be freed when the client dies */
|
* should be freed when the client dies */
|
||||||
if ((pmap->numPixelsRed[client] == 1) &&
|
if ((pmap->numPixelsRed[client] == 1) &&
|
||||||
(CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) {
|
(CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) {
|
||||||
colorResource *pcr;
|
colorResource *pcr = calloc(1, sizeof(colorResource));
|
||||||
|
|
||||||
pcr = malloc(sizeof(colorResource));
|
|
||||||
if (!pcr) {
|
if (!pcr) {
|
||||||
(void) FreeColors(pmap, client, 1, pPix, (Pixel) 0);
|
(void) FreeColors(pmap, client, 1, pPix, (Pixel) 0);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
@ -1503,7 +1501,7 @@ AllocColorCells(int client, ColormapPtr pmap, int colors, int planes,
|
||||||
if (pmap->class == DirectColor)
|
if (pmap->class == DirectColor)
|
||||||
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
|
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
|
||||||
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
|
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
|
||||||
pcr = malloc(sizeof(colorResource));
|
pcr = calloc(1, sizeof(colorResource));
|
||||||
if (!pcr)
|
if (!pcr)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1568,7 @@ AllocColorPlanes(int client, ColormapPtr pmap, int colors,
|
||||||
if (class == DirectColor)
|
if (class == DirectColor)
|
||||||
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
|
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
|
||||||
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
|
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
|
||||||
pcr = malloc(sizeof(colorResource));
|
pcr = calloc(1, sizeof(colorResource));
|
||||||
if (!pcr)
|
if (!pcr)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
@ -1973,7 +1971,7 @@ AllocShared(ColormapPtr pmap, Pixel * ppix, int c, int r, int g, int b,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ppshared = psharedList;
|
ppshared = psharedList;
|
||||||
for (z = npixShared; --z >= 0;) {
|
for (z = npixShared; --z >= 0;) {
|
||||||
if (!(ppshared[z] = malloc(sizeof(SHAREDCOLOR)))) {
|
if (!(ppshared[z] = calloc(1, sizeof(SHAREDCOLOR)))) {
|
||||||
for (z++; z < npixShared; z++)
|
for (z++; z < npixShared; z++)
|
||||||
free(ppshared[z]);
|
free(ppshared[z]);
|
||||||
free(psharedList);
|
free(psharedList);
|
||||||
|
|
|
@ -376,7 +376,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
unsigned char *mskptr;
|
unsigned char *mskptr;
|
||||||
|
|
||||||
n = BitmapBytePad(cm.width) * (long) cm.height;
|
n = BitmapBytePad(cm.width) * (long) cm.height;
|
||||||
mskptr = mskbits = malloc(n);
|
mskptr = mskbits = calloc(1, n);
|
||||||
if (!mskptr)
|
if (!mskptr)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
while (--n >= 0)
|
while (--n >= 0)
|
||||||
|
@ -427,7 +427,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
bits->refcnt = -1;
|
bits->refcnt = -1;
|
||||||
else {
|
else {
|
||||||
bits->refcnt = 1;
|
bits->refcnt = 1;
|
||||||
pShare = malloc(sizeof(GlyphShare));
|
pShare = calloc(1, sizeof(GlyphShare));
|
||||||
if (!pShare) {
|
if (!pShare) {
|
||||||
FreeCursorBits(bits);
|
FreeCursorBits(bits);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
|
@ -1202,7 +1202,7 @@ CloseOneDevice(const DeviceIntPtr dev, DeviceIntPtr *listHead)
|
||||||
* the removal of the device.
|
* the removal of the device.
|
||||||
*
|
*
|
||||||
* No PresenceNotify is sent for device that the client never saw. This can
|
* No PresenceNotify is sent for device that the client never saw. This can
|
||||||
* happen if a malloc fails during the addition of master devices. If
|
* happen if a calloc fails during the addition of master devices. If
|
||||||
* dev->init is FALSE it means the client never received a DeviceAdded event,
|
* dev->init is FALSE it means the client never received a DeviceAdded event,
|
||||||
* so let's not send a DeviceRemoved event either.
|
* so let's not send a DeviceRemoved event either.
|
||||||
*
|
*
|
||||||
|
@ -1475,12 +1475,10 @@ InitPointerAccelerationScheme(DeviceIntPtr dev, int scheme)
|
||||||
Bool
|
Bool
|
||||||
InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
||||||
{
|
{
|
||||||
FocusClassPtr focc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
BUG_RETURN_VAL(dev->focus != NULL, FALSE);
|
BUG_RETURN_VAL(dev->focus != NULL, FALSE);
|
||||||
|
|
||||||
focc = malloc(sizeof(FocusClassRec));
|
FocusClassPtr focc = calloc(1, sizeof(FocusClassRec));
|
||||||
if (!focc)
|
if (!focc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
UpdateCurrentTimeIf();
|
UpdateCurrentTimeIf();
|
||||||
|
@ -1498,11 +1496,9 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
||||||
Bool
|
Bool
|
||||||
InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
|
InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
PtrFeedbackPtr feedc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(PtrFeedbackClassRec));
|
PtrFeedbackPtr feedc = calloc(1, sizeof(PtrFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
feedc->CtrlProc = controlProc;
|
feedc->CtrlProc = controlProc;
|
||||||
|
@ -1541,11 +1537,10 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
||||||
KeySym * symbols)
|
KeySym * symbols)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
StringFeedbackPtr feedc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(StringFeedbackClassRec));
|
StringFeedbackPtr feedc = calloc(1, sizeof(StringFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
feedc->CtrlProc = controlProc;
|
feedc->CtrlProc = controlProc;
|
||||||
|
@ -1577,11 +1572,9 @@ Bool
|
||||||
InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
|
InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
|
||||||
BellCtrlProcPtr controlProc)
|
BellCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
BellFeedbackPtr feedc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(BellFeedbackClassRec));
|
BellFeedbackPtr feedc = calloc(1, sizeof(BellFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
feedc->CtrlProc = controlProc;
|
feedc->CtrlProc = controlProc;
|
||||||
|
@ -1598,11 +1591,9 @@ InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
|
||||||
Bool
|
Bool
|
||||||
InitLedFeedbackClassDeviceStruct(DeviceIntPtr dev, LedCtrlProcPtr controlProc)
|
InitLedFeedbackClassDeviceStruct(DeviceIntPtr dev, LedCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
LedFeedbackPtr feedc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(LedFeedbackClassRec));
|
LedFeedbackPtr feedc = calloc(1, sizeof(LedFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
feedc->CtrlProc = controlProc;
|
feedc->CtrlProc = controlProc;
|
||||||
|
@ -1620,11 +1611,9 @@ Bool
|
||||||
InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
||||||
IntegerCtrlProcPtr controlProc)
|
IntegerCtrlProcPtr controlProc)
|
||||||
{
|
{
|
||||||
IntegerFeedbackPtr feedc;
|
|
||||||
|
|
||||||
BUG_RETURN_VAL(dev == NULL, FALSE);
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
||||||
|
|
||||||
feedc = malloc(sizeof(IntegerFeedbackClassRec));
|
IntegerFeedbackPtr feedc = calloc(1, sizeof(IntegerFeedbackClassRec));
|
||||||
if (!feedc)
|
if (!feedc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
feedc->CtrlProc = controlProc;
|
feedc->CtrlProc = controlProc;
|
||||||
|
|
|
@ -628,7 +628,7 @@ CreateConnectionBlock(void)
|
||||||
pad_to_int32(setup.nbytesVendor) +
|
pad_to_int32(setup.nbytesVendor) +
|
||||||
(setup.numFormats * sizeof(xPixmapFormat)) +
|
(setup.numFormats * sizeof(xPixmapFormat)) +
|
||||||
(setup.numRoots * sizeof(xWindowRoot));
|
(setup.numRoots * sizeof(xWindowRoot));
|
||||||
ConnectionInfo = malloc(lenofblock);
|
ConnectionInfo = calloc(1, lenofblock);
|
||||||
if (!ConnectionInfo)
|
if (!ConnectionInfo)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -2559,7 +2559,6 @@ ProcUninstallColormap(ClientPtr client)
|
||||||
int
|
int
|
||||||
ProcListInstalledColormaps(ClientPtr client)
|
ProcListInstalledColormaps(ClientPtr client)
|
||||||
{
|
{
|
||||||
xListInstalledColormapsReply *preply;
|
|
||||||
int nummaps, rc;
|
int nummaps, rc;
|
||||||
WindowPtr pWin;
|
WindowPtr pWin;
|
||||||
|
|
||||||
|
@ -2574,7 +2573,8 @@ ProcListInstalledColormaps(ClientPtr client)
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
preply = malloc(sizeof(xListInstalledColormapsReply) +
|
xListInstalledColormapsReply *preply = calloc(1,
|
||||||
|
sizeof(xListInstalledColormapsReply) +
|
||||||
pWin->drawable.pScreen->maxInstalledCmaps *
|
pWin->drawable.pScreen->maxInstalledCmaps *
|
||||||
sizeof(Colormap));
|
sizeof(Colormap));
|
||||||
if (!preply)
|
if (!preply)
|
||||||
|
@ -2689,7 +2689,7 @@ ProcAllocColorCells(ClientPtr client)
|
||||||
if (rc == Success) {
|
if (rc == Success) {
|
||||||
int npixels, nmasks;
|
int npixels, nmasks;
|
||||||
long length;
|
long length;
|
||||||
Pixel *ppixels, *pmasks;
|
Pixel *pmasks;
|
||||||
|
|
||||||
npixels = stuff->colors;
|
npixels = stuff->colors;
|
||||||
if (!npixels) {
|
if (!npixels) {
|
||||||
|
@ -2702,7 +2702,7 @@ ProcAllocColorCells(ClientPtr client)
|
||||||
}
|
}
|
||||||
nmasks = stuff->planes;
|
nmasks = stuff->planes;
|
||||||
length = ((long) npixels + (long) nmasks) * sizeof(Pixel);
|
length = ((long) npixels + (long) nmasks) * sizeof(Pixel);
|
||||||
ppixels = malloc(length);
|
Pixel *ppixels = calloc(1, length);
|
||||||
if (!ppixels)
|
if (!ppixels)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
pmasks = ppixels + npixels;
|
pmasks = ppixels + npixels;
|
||||||
|
@ -2751,7 +2751,6 @@ ProcAllocColorPlanes(ClientPtr client)
|
||||||
xAllocColorPlanesReply acpr;
|
xAllocColorPlanesReply acpr;
|
||||||
int npixels;
|
int npixels;
|
||||||
long length;
|
long length;
|
||||||
Pixel *ppixels;
|
|
||||||
|
|
||||||
npixels = stuff->colors;
|
npixels = stuff->colors;
|
||||||
if (!npixels) {
|
if (!npixels) {
|
||||||
|
@ -2769,7 +2768,7 @@ ProcAllocColorPlanes(ClientPtr client)
|
||||||
};
|
};
|
||||||
length = (long) npixels *sizeof(Pixel);
|
length = (long) npixels *sizeof(Pixel);
|
||||||
|
|
||||||
ppixels = malloc(length);
|
Pixel *ppixels = calloc(1, length);
|
||||||
if (!ppixels)
|
if (!ppixels)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
|
if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
|
||||||
|
@ -2981,7 +2980,6 @@ ProcCreateCursor(ClientPtr client)
|
||||||
PixmapPtr src;
|
PixmapPtr src;
|
||||||
PixmapPtr msk;
|
PixmapPtr msk;
|
||||||
unsigned char *srcbits;
|
unsigned char *srcbits;
|
||||||
unsigned char *mskbits;
|
|
||||||
unsigned short width, height;
|
unsigned short width, height;
|
||||||
long n;
|
long n;
|
||||||
CursorMetricRec cm;
|
CursorMetricRec cm;
|
||||||
|
@ -3029,7 +3027,8 @@ ProcCreateCursor(ClientPtr client)
|
||||||
if (!srcbits)
|
if (!srcbits)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
n = BitmapBytePad(width) * height;
|
n = BitmapBytePad(width) * height;
|
||||||
mskbits = malloc(n);
|
|
||||||
|
unsigned char *mskbits = calloc(1, n);
|
||||||
if (!mskbits) {
|
if (!mskbits) {
|
||||||
free(srcbits);
|
free(srcbits);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
|
@ -379,7 +379,6 @@ int
|
||||||
OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
|
OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
|
||||||
const char *pfontname)
|
const char *pfontname)
|
||||||
{
|
{
|
||||||
OFclosurePtr c;
|
|
||||||
int i;
|
int i;
|
||||||
FontPtr cached = (FontPtr) 0;
|
FontPtr cached = (FontPtr) 0;
|
||||||
|
|
||||||
|
@ -412,10 +411,10 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c = malloc(sizeof(OFclosureRec));
|
OFclosurePtr c = calloc(1, sizeof(OFclosureRec));
|
||||||
if (!c)
|
if (!c)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
c->fontname = malloc(lenfname);
|
c->fontname = calloc(1, lenfname);
|
||||||
c->origFontName = pfontname;
|
c->origFontName = pfontname;
|
||||||
c->origFontNameLen = lenfname;
|
c->origFontNameLen = lenfname;
|
||||||
if (!c->fontname) {
|
if (!c->fontname) {
|
||||||
|
@ -644,7 +643,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
|
||||||
}
|
}
|
||||||
if (err == FontNameAlias) {
|
if (err == FontNameAlias) {
|
||||||
free(resolved);
|
free(resolved);
|
||||||
resolved = malloc(resolvedlen + 1);
|
resolved = calloc(1, resolvedlen + 1);
|
||||||
if (resolved)
|
if (resolved)
|
||||||
memcpy(resolved, tmpname, resolvedlen + 1);
|
memcpy(resolved, tmpname, resolvedlen + 1);
|
||||||
}
|
}
|
||||||
|
@ -694,7 +693,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
|
||||||
c->saved = c->current;
|
c->saved = c->current;
|
||||||
c->haveSaved = TRUE;
|
c->haveSaved = TRUE;
|
||||||
free(c->savedName);
|
free(c->savedName);
|
||||||
c->savedName = malloc(namelen + 1);
|
c->savedName = calloc(1, namelen + 1);
|
||||||
if (c->savedName)
|
if (c->savedName)
|
||||||
memcpy(c->savedName, name, namelen + 1);
|
memcpy(c->savedName, name, namelen + 1);
|
||||||
c->savedNameLen = namelen;
|
c->savedNameLen = namelen;
|
||||||
|
@ -756,7 +755,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
|
||||||
.sequenceNumber = client->sequence
|
.sequenceNumber = client->sequence
|
||||||
};
|
};
|
||||||
|
|
||||||
bufptr = bufferStart = malloc(reply.length << 2);
|
bufptr = bufferStart = calloc(1, reply.length << 2);
|
||||||
|
|
||||||
if (!bufptr && reply.length) {
|
if (!bufptr && reply.length) {
|
||||||
SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
|
SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
|
||||||
|
@ -814,7 +813,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
|
||||||
if (i != Success)
|
if (i != Success)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
if (!(c = malloc(sizeof *c)))
|
if (!(c = calloc(1, sizeof *c)))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
||||||
if (!c->fpe_list) {
|
if (!c->fpe_list) {
|
||||||
|
@ -934,7 +933,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
|
||||||
c->haveSaved = TRUE;
|
c->haveSaved = TRUE;
|
||||||
c->savedNumFonts = numFonts;
|
c->savedNumFonts = numFonts;
|
||||||
free(c->savedName);
|
free(c->savedName);
|
||||||
c->savedName = malloc(namelen + 1);
|
c->savedName = calloc(1, namelen + 1);
|
||||||
if (c->savedName)
|
if (c->savedName)
|
||||||
memcpy(c->savedName, name, namelen + 1);
|
memcpy(c->savedName, name, namelen + 1);
|
||||||
aliascount = 20;
|
aliascount = 20;
|
||||||
|
@ -1060,7 +1059,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
|
||||||
if (i != Success)
|
if (i != Success)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
if (!(c = malloc(sizeof *c)))
|
if (!(c = calloc(1, sizeof *c)))
|
||||||
goto badAlloc;
|
goto badAlloc;
|
||||||
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
||||||
if (!c->fpe_list) {
|
if (!c->fpe_list) {
|
||||||
|
@ -1219,7 +1218,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
|
||||||
/* We're putting the client to sleep. We need to do a few things
|
/* We're putting the client to sleep. We need to do a few things
|
||||||
to ensure successful and atomic-appearing execution of the
|
to ensure successful and atomic-appearing execution of the
|
||||||
remainder of the request. First, copy the remainder of the
|
remainder of the request. First, copy the remainder of the
|
||||||
request into a safe malloc'd area. Second, create a scratch GC
|
request into a safe calloc'd area. Second, create a scratch GC
|
||||||
to use for the remainder of the request. Third, mark all fonts
|
to use for the remainder of the request. Third, mark all fonts
|
||||||
referenced in the remainder of the request to prevent their
|
referenced in the remainder of the request to prevent their
|
||||||
deallocation. Fourth, make the original GC look like the
|
deallocation. Fourth, make the original GC look like the
|
||||||
|
@ -1231,9 +1230,9 @@ doPolyText(ClientPtr client, PTclosurePtr c)
|
||||||
indicated by client_state = START_SLEEP. */
|
indicated by client_state = START_SLEEP. */
|
||||||
|
|
||||||
/* Step 1 */
|
/* Step 1 */
|
||||||
/* Allocate a malloc'd closure structure to replace
|
/* Allocate a calloc'd closure structure to replace
|
||||||
the local one we were passed */
|
the local one we were passed */
|
||||||
new_closure = malloc(sizeof(PTclosureRec));
|
new_closure = calloc(1, sizeof(PTclosureRec));
|
||||||
if (!new_closure) {
|
if (!new_closure) {
|
||||||
err = BadAlloc;
|
err = BadAlloc;
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -1241,7 +1240,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
|
||||||
*new_closure = *c;
|
*new_closure = *c;
|
||||||
|
|
||||||
len = new_closure->endReq - new_closure->pElt;
|
len = new_closure->endReq - new_closure->pElt;
|
||||||
new_closure->data = malloc(len);
|
new_closure->data = calloc(1, len);
|
||||||
if (!new_closure->data) {
|
if (!new_closure->data) {
|
||||||
free(new_closure);
|
free(new_closure);
|
||||||
err = BadAlloc;
|
err = BadAlloc;
|
||||||
|
@ -1415,7 +1414,6 @@ doImageText(ClientPtr client, ITclosurePtr c)
|
||||||
if (!ClientIsAsleep(client)) {
|
if (!ClientIsAsleep(client)) {
|
||||||
GC *pGC;
|
GC *pGC;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
ITclosurePtr new_closure;
|
|
||||||
ITclosurePtr old_closure;
|
ITclosurePtr old_closure;
|
||||||
|
|
||||||
/* We're putting the client to sleep. We need to
|
/* We're putting the client to sleep. We need to
|
||||||
|
@ -1423,7 +1421,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
|
||||||
in doPolyText, but much simpler because the
|
in doPolyText, but much simpler because the
|
||||||
request structure is much simpler. */
|
request structure is much simpler. */
|
||||||
|
|
||||||
new_closure = malloc(sizeof(ITclosureRec));
|
ITclosurePtr new_closure = calloc(1, sizeof(ITclosureRec));
|
||||||
if (!new_closure) {
|
if (!new_closure) {
|
||||||
err = BadAlloc;
|
err = BadAlloc;
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -1624,13 +1622,12 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
|
||||||
}
|
}
|
||||||
/* if error or can't do it, act like it's a new one */
|
/* if error or can't do it, act like it's a new one */
|
||||||
if (!fpe) {
|
if (!fpe) {
|
||||||
char *name;
|
fpe = calloc(1, sizeof(FontPathElementRec));
|
||||||
fpe = malloc(sizeof(FontPathElementRec));
|
|
||||||
if (!fpe) {
|
if (!fpe) {
|
||||||
err = BadAlloc;
|
err = BadAlloc;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
name = malloc(len + 1);
|
char *name = calloc(1, len + 1);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
free(fpe);
|
free(fpe);
|
||||||
err = BadAlloc;
|
err = BadAlloc;
|
||||||
|
@ -1737,7 +1734,7 @@ SetDefaultFontPath(const char *path)
|
||||||
|
|
||||||
/* get enough for string, plus values -- use up commas */
|
/* get enough for string, plus values -- use up commas */
|
||||||
len = strlen(temp_path) + 1;
|
len = strlen(temp_path) + 1;
|
||||||
nump = cp = newpath = malloc(len);
|
nump = cp = newpath = calloc(1, len);
|
||||||
if (!newpath) {
|
if (!newpath) {
|
||||||
free(temp_path);
|
free(temp_path);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
|
@ -531,9 +531,7 @@ Bool
|
||||||
QueueWorkProc(Bool (*function) (ClientPtr pClient, void *closure),
|
QueueWorkProc(Bool (*function) (ClientPtr pClient, void *closure),
|
||||||
ClientPtr client, void *closure)
|
ClientPtr client, void *closure)
|
||||||
{
|
{
|
||||||
WorkQueuePtr q;
|
WorkQueuePtr q = calloc(1, sizeof *q);
|
||||||
|
|
||||||
q = malloc(sizeof *q);
|
|
||||||
if (!q)
|
if (!q)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
q->function = function;
|
q->function = function;
|
||||||
|
@ -565,9 +563,7 @@ static SleepQueuePtr sleepQueue = NULL;
|
||||||
Bool
|
Bool
|
||||||
ClientSleep(ClientPtr client, ClientSleepProcPtr function, void *closure)
|
ClientSleep(ClientPtr client, ClientSleepProcPtr function, void *closure)
|
||||||
{
|
{
|
||||||
SleepQueuePtr q;
|
SleepQueuePtr q = calloc(1, sizeof *q);
|
||||||
|
|
||||||
q = malloc(sizeof *q);
|
|
||||||
if (!q)
|
if (!q)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -653,9 +649,7 @@ static CallbackListPtr **listsToCleanup = NULL;
|
||||||
static Bool
|
static Bool
|
||||||
_AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void *data)
|
_AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void *data)
|
||||||
{
|
{
|
||||||
CallbackPtr cbr;
|
CallbackPtr cbr = calloc(1, sizeof(CallbackRec));
|
||||||
|
|
||||||
cbr = malloc(sizeof(CallbackRec));
|
|
||||||
if (!cbr)
|
if (!cbr)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
cbr->proc = callback;
|
cbr->proc = callback;
|
||||||
|
@ -774,12 +768,12 @@ void DeleteCallbackList(CallbackListPtr *pcbl)
|
||||||
static Bool
|
static Bool
|
||||||
CreateCallbackList(CallbackListPtr *pcbl)
|
CreateCallbackList(CallbackListPtr *pcbl)
|
||||||
{
|
{
|
||||||
CallbackListPtr cbl;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!pcbl)
|
if (!pcbl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
cbl = malloc(sizeof(CallbackListRec));
|
|
||||||
|
CallbackListPtr cbl = calloc(1, sizeof(CallbackListRec));
|
||||||
if (!cbl)
|
if (!cbl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
cbl->inCallback = 0;
|
cbl->inCallback = 0;
|
||||||
|
|
|
@ -1143,7 +1143,6 @@ void
|
||||||
EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
|
EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
|
||||||
{
|
{
|
||||||
QdEventPtr tail = NULL;
|
QdEventPtr tail = NULL;
|
||||||
QdEventPtr qe;
|
|
||||||
SpritePtr pSprite = device->spriteInfo->sprite;
|
SpritePtr pSprite = device->spriteInfo->sprite;
|
||||||
int eventlen;
|
int eventlen;
|
||||||
DeviceEvent *event = &ev->device_event;
|
DeviceEvent *event = &ev->device_event;
|
||||||
|
@ -1204,7 +1203,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
|
||||||
|
|
||||||
eventlen = sizeof(InternalEvent);
|
eventlen = sizeof(InternalEvent);
|
||||||
|
|
||||||
qe = malloc(sizeof(QdEventRec) + eventlen);
|
QdEventPtr qe = calloc(1, sizeof(QdEventRec) + eventlen);
|
||||||
if (!qe)
|
if (!qe)
|
||||||
return;
|
return;
|
||||||
xorg_list_init(&qe->next);
|
xorg_list_init(&qe->next);
|
||||||
|
@ -4588,7 +4587,7 @@ XRetCode EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
|
||||||
check = 0;
|
check = 0;
|
||||||
if (!pWin->optional && !MakeWindowOptional(pWin))
|
if (!pWin->optional && !MakeWindowOptional(pWin))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
others = malloc(sizeof(OtherClients));
|
others = calloc(1, sizeof(OtherClients));
|
||||||
if (!others)
|
if (!others)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
others->mask = mask;
|
others->mask = mask;
|
||||||
|
|
|
@ -284,7 +284,7 @@ ProcListExtensions(ClientPtr client)
|
||||||
reply.nExtensions += 1;
|
reply.nExtensions += 1;
|
||||||
}
|
}
|
||||||
reply.length = bytes_to_int32(total_length);
|
reply.length = bytes_to_int32(total_length);
|
||||||
buffer = bufptr = malloc(total_length);
|
buffer = bufptr = calloc(1, total_length);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
for (i = 0; i < NumExtensions; i++) {
|
for (i = 0; i < NumExtensions; i++) {
|
||||||
|
|
16
dix/gc.c
16
dix/gc.c
|
@ -361,9 +361,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (newdash != 0) {
|
else if (newdash != 0) {
|
||||||
unsigned char *dash;
|
unsigned char *dash = calloc(2, sizeof(unsigned char));
|
||||||
|
|
||||||
dash = malloc(2 * sizeof(unsigned char));
|
|
||||||
if (dash) {
|
if (dash) {
|
||||||
if (pGC->dash != DefaultDash)
|
if (pGC->dash != DefaultDash)
|
||||||
free(pGC->dash);
|
free(pGC->dash);
|
||||||
|
@ -726,10 +724,8 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned char *dash;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
unsigned char *dash = calloc(pgcSrc->numInDashList, sizeof(unsigned char));
|
||||||
dash = malloc(pgcSrc->numInDashList * sizeof(unsigned char));
|
|
||||||
if (dash) {
|
if (dash) {
|
||||||
if (pgcDst->dash != DefaultDash)
|
if (pgcDst->dash != DefaultDash)
|
||||||
free(pgcDst->dash);
|
free(pgcDst->dash);
|
||||||
|
@ -920,9 +916,9 @@ SetDashes(GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ndash & 1)
|
if (ndash & 1)
|
||||||
p = malloc(2 * ndash * sizeof(unsigned char));
|
p = calloc(2 * ndash, sizeof(unsigned char));
|
||||||
else
|
else
|
||||||
p = malloc(ndash * sizeof(unsigned char));
|
p = calloc(ndash, sizeof(unsigned char));
|
||||||
if (!p)
|
if (!p)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
||||||
|
@ -1001,13 +997,13 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects,
|
||||||
xRectangle *prects, int ordering)
|
xRectangle *prects, int ordering)
|
||||||
{
|
{
|
||||||
int newct, size;
|
int newct, size;
|
||||||
xRectangle *prectsNew;
|
|
||||||
|
|
||||||
newct = VerifyRectOrder(nrects, prects, ordering);
|
newct = VerifyRectOrder(nrects, prects, ordering);
|
||||||
if (newct < 0)
|
if (newct < 0)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
size = nrects * sizeof(xRectangle);
|
size = nrects * sizeof(xRectangle);
|
||||||
prectsNew = malloc(size);
|
|
||||||
|
xRectangle *prectsNew = calloc(1, size);
|
||||||
if (!prectsNew && size)
|
if (!prectsNew && size)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord ** buff, unsigned long start,
|
||||||
else
|
else
|
||||||
size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
|
size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
|
||||||
|
|
||||||
*buff = malloc(size * pDev->valuator->numMotionEvents);
|
*buff = calloc(size, pDev->valuator->numMotionEvents);
|
||||||
if (!(*buff))
|
if (!(*buff))
|
||||||
return 0;
|
return 0;
|
||||||
obuff = (char *) *buff;
|
obuff = (char *) *buff;
|
||||||
|
|
|
@ -279,7 +279,7 @@ CopyGrab(GrabPtr dst, const GrabPtr src)
|
||||||
if (src->modifiersDetail.pMask) {
|
if (src->modifiersDetail.pMask) {
|
||||||
int len = MasksPerDetailMask * sizeof(Mask);
|
int len = MasksPerDetailMask * sizeof(Mask);
|
||||||
|
|
||||||
mdetails_mask = malloc(len);
|
mdetails_mask = calloc(1, len);
|
||||||
if (!mdetails_mask)
|
if (!mdetails_mask)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
memcpy(mdetails_mask, src->modifiersDetail.pMask, len);
|
memcpy(mdetails_mask, src->modifiersDetail.pMask, len);
|
||||||
|
@ -288,7 +288,7 @@ CopyGrab(GrabPtr dst, const GrabPtr src)
|
||||||
if (src->detail.pMask) {
|
if (src->detail.pMask) {
|
||||||
int len = MasksPerDetailMask * sizeof(Mask);
|
int len = MasksPerDetailMask * sizeof(Mask);
|
||||||
|
|
||||||
details_mask = malloc(len);
|
details_mask = calloc(1, len);
|
||||||
if (!details_mask) {
|
if (!details_mask) {
|
||||||
free(mdetails_mask);
|
free(mdetails_mask);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -345,10 +345,9 @@ DeletePassiveGrab(void *value, XID id)
|
||||||
static Mask *
|
static Mask *
|
||||||
DeleteDetailFromMask(Mask *pDetailMask, unsigned int detail)
|
DeleteDetailFromMask(Mask *pDetailMask, unsigned int detail)
|
||||||
{
|
{
|
||||||
Mask *mask;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mask = malloc(sizeof(Mask) * MasksPerDetailMask);
|
Mask *mask = calloc(MasksPerDetailMask, sizeof(Mask));
|
||||||
if (mask) {
|
if (mask) {
|
||||||
if (pDetailMask)
|
if (pDetailMask)
|
||||||
for (i = 0; i < MasksPerDetailMask; i++)
|
for (i = 0; i < MasksPerDetailMask; i++)
|
||||||
|
|
|
@ -469,7 +469,6 @@ _dixAllocateObjectWithPrivates(unsigned baseSize, unsigned clear,
|
||||||
unsigned offset, DevPrivateType type)
|
unsigned offset, DevPrivateType type)
|
||||||
{
|
{
|
||||||
unsigned totalSize;
|
unsigned totalSize;
|
||||||
void *object;
|
|
||||||
PrivatePtr privates;
|
PrivatePtr privates;
|
||||||
PrivatePtr *devPrivates;
|
PrivatePtr *devPrivates;
|
||||||
|
|
||||||
|
@ -480,7 +479,7 @@ _dixAllocateObjectWithPrivates(unsigned baseSize, unsigned clear,
|
||||||
/* round up so that void * is aligned */
|
/* round up so that void * is aligned */
|
||||||
baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
|
baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
|
||||||
totalSize = baseSize + global_keys[type].offset;
|
totalSize = baseSize + global_keys[type].offset;
|
||||||
object = malloc(totalSize);
|
void *object = calloc(1, totalSize);
|
||||||
if (!object)
|
if (!object)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -512,7 +511,7 @@ dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type)
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(p = malloc(size)))
|
if (!(p = calloc(1, size)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +691,6 @@ _dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen,
|
||||||
DevPrivateType type)
|
DevPrivateType type)
|
||||||
{
|
{
|
||||||
unsigned totalSize;
|
unsigned totalSize;
|
||||||
void *object;
|
|
||||||
PrivatePtr privates;
|
PrivatePtr privates;
|
||||||
PrivatePtr *devPrivates;
|
PrivatePtr *devPrivates;
|
||||||
int privates_size;
|
int privates_size;
|
||||||
|
@ -708,7 +706,7 @@ _dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen,
|
||||||
/* round up so that pointer is aligned */
|
/* round up so that pointer is aligned */
|
||||||
baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
|
baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
|
||||||
totalSize = baseSize + privates_size;
|
totalSize = baseSize + privates_size;
|
||||||
object = malloc(totalSize);
|
void *object = calloc(1, totalSize);
|
||||||
if (!object)
|
if (!object)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,6 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
PropertyPtr pProp;
|
PropertyPtr pProp;
|
||||||
PropertyRec savedProp;
|
PropertyRec savedProp;
|
||||||
int sizeInBytes, totalSize, rc;
|
int sizeInBytes, totalSize, rc;
|
||||||
unsigned char *data;
|
|
||||||
Mask access_mode;
|
Mask access_mode;
|
||||||
|
|
||||||
sizeInBytes = format >> 3;
|
sizeInBytes = format >> 3;
|
||||||
|
@ -278,7 +277,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
|
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
|
||||||
if (!pProp)
|
if (!pProp)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
data = malloc(totalSize);
|
unsigned char *data = calloc(1, totalSize);
|
||||||
if (totalSize) {
|
if (totalSize) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||||
|
@ -317,7 +316,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
savedProp = *pProp;
|
savedProp = *pProp;
|
||||||
|
|
||||||
if (mode == PropModeReplace) {
|
if (mode == PropModeReplace) {
|
||||||
data = malloc(totalSize);
|
unsigned char *data = calloc(1, totalSize);
|
||||||
if (totalSize) {
|
if (totalSize) {
|
||||||
if (!data)
|
if (!data)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
@ -332,7 +331,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
else if (mode == PropModeAppend) {
|
else if (mode == PropModeAppend) {
|
||||||
data = xallocarray(pProp->size + len, sizeInBytes);
|
unsigned char *data = calloc(pProp->size + len, sizeInBytes);
|
||||||
if (!data)
|
if (!data)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
memcpy(data, pProp->data, pProp->size * sizeInBytes);
|
memcpy(data, pProp->data, pProp->size * sizeInBytes);
|
||||||
|
@ -341,7 +340,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
pProp->size += len;
|
pProp->size += len;
|
||||||
}
|
}
|
||||||
else if (mode == PropModePrepend) {
|
else if (mode == PropModePrepend) {
|
||||||
data = xallocarray(len + pProp->size, sizeInBytes);
|
unsigned char *data = calloc(len + pProp->size, sizeInBytes);
|
||||||
if (!data)
|
if (!data)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
|
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
|
||||||
|
|
16
dix/region.c
16
dix/region.c
|
@ -235,16 +235,14 @@ InitRegions(void)
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
* RegionCreate(rect, size)
|
* RegionCreate(rect, size)
|
||||||
* This routine does a simple malloc to make a structure of
|
* This routine does a simple calloc to make a structure of
|
||||||
* REGION of "size" number of rectangles.
|
* REGION of "size" number of rectangles.
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
RegionPtr
|
RegionPtr
|
||||||
RegionCreate(BoxPtr rect, int size)
|
RegionCreate(BoxPtr rect, int size)
|
||||||
{
|
{
|
||||||
RegionPtr pReg;
|
RegionPtr pReg = calloc(1, sizeof(RegionRec));
|
||||||
|
|
||||||
pReg = (RegionPtr) malloc(sizeof(RegionRec));
|
|
||||||
if (!pReg)
|
if (!pReg)
|
||||||
return &RegionBrokenRegion;
|
return &RegionBrokenRegion;
|
||||||
|
|
||||||
|
@ -356,7 +354,7 @@ RegionRectAlloc(RegionPtr pRgn, int n)
|
||||||
if (!pRgn->data) {
|
if (!pRgn->data) {
|
||||||
n++;
|
n++;
|
||||||
rgnSize = RegionSizeof(n);
|
rgnSize = RegionSizeof(n);
|
||||||
pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL;
|
pRgn->data = (rgnSize > 0) ? calloc(1, rgnSize) : NULL;
|
||||||
if (!pRgn->data)
|
if (!pRgn->data)
|
||||||
return RegionBreak(pRgn);
|
return RegionBreak(pRgn);
|
||||||
pRgn->data->numRects = 1;
|
pRgn->data->numRects = 1;
|
||||||
|
@ -364,7 +362,7 @@ RegionRectAlloc(RegionPtr pRgn, int n)
|
||||||
}
|
}
|
||||||
else if (!pRgn->data->size) {
|
else if (!pRgn->data->size) {
|
||||||
rgnSize = RegionSizeof(n);
|
rgnSize = RegionSizeof(n);
|
||||||
pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL;
|
pRgn->data = (rgnSize > 0) ? calloc(1, rgnSize) : NULL;
|
||||||
if (!pRgn->data)
|
if (!pRgn->data)
|
||||||
return RegionBreak(pRgn);
|
return RegionBreak(pRgn);
|
||||||
pRgn->data->numRects = 0;
|
pRgn->data->numRects = 0;
|
||||||
|
@ -1150,7 +1148,6 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
|
||||||
} RegionInfo;
|
} RegionInfo;
|
||||||
|
|
||||||
int numRects; /* Original numRects for badreg */
|
int numRects; /* Original numRects for badreg */
|
||||||
RegionInfo *ri; /* Array of current regions */
|
|
||||||
int numRI; /* Number of entries used in ri */
|
int numRI; /* Number of entries used in ri */
|
||||||
int sizeRI; /* Number of entries available in ri */
|
int sizeRI; /* Number of entries available in ri */
|
||||||
int i; /* Index into rects */
|
int i; /* Index into rects */
|
||||||
|
@ -1193,7 +1190,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
|
||||||
|
|
||||||
/* Set up the first region to be the first rectangle in badreg */
|
/* Set up the first region to be the first rectangle in badreg */
|
||||||
/* Note that step 2 code will never overflow the ri[0].reg rects array */
|
/* Note that step 2 code will never overflow the ri[0].reg rects array */
|
||||||
ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo));
|
RegionInfo *ri = calloc(4, sizeof(RegionInfo));
|
||||||
if (!ri)
|
if (!ri)
|
||||||
return RegionBreak(badreg);
|
return RegionBreak(badreg);
|
||||||
sizeRI = 4;
|
sizeRI = 4;
|
||||||
|
@ -1324,7 +1321,6 @@ RegionFromRects(int nrects, xRectangle *prect, int ctype)
|
||||||
|
|
||||||
RegionPtr pRgn;
|
RegionPtr pRgn;
|
||||||
size_t rgnSize;
|
size_t rgnSize;
|
||||||
RegDataPtr pData;
|
|
||||||
BoxPtr pBox;
|
BoxPtr pBox;
|
||||||
int i;
|
int i;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
@ -1351,7 +1347,7 @@ RegionFromRects(int nrects, xRectangle *prect, int ctype)
|
||||||
return pRgn;
|
return pRgn;
|
||||||
}
|
}
|
||||||
rgnSize = RegionSizeof(nrects);
|
rgnSize = RegionSizeof(nrects);
|
||||||
pData = (rgnSize > 0) ? malloc(rgnSize) : NULL;
|
RegDataPtr pData = (rgnSize > 0) ? calloc(1, rgnSize) : NULL;
|
||||||
if (!pData) {
|
if (!pData) {
|
||||||
RegionBreak(pRgn);
|
RegionBreak(pRgn);
|
||||||
return pRgn;
|
return pRgn;
|
||||||
|
|
|
@ -650,13 +650,13 @@ InitClientResources(ClientPtr client)
|
||||||
lastResourceClass = RC_LASTPREDEF;
|
lastResourceClass = RC_LASTPREDEF;
|
||||||
TypeMask = RC_LASTPREDEF - 1;
|
TypeMask = RC_LASTPREDEF - 1;
|
||||||
free(resourceTypes);
|
free(resourceTypes);
|
||||||
resourceTypes = malloc(sizeof(predefTypes));
|
resourceTypes = calloc(1, sizeof(predefTypes));
|
||||||
if (!resourceTypes)
|
if (!resourceTypes)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
memcpy(resourceTypes, predefTypes, sizeof(predefTypes));
|
memcpy(resourceTypes, predefTypes, sizeof(predefTypes));
|
||||||
}
|
}
|
||||||
clientTable[i = client->index].resources =
|
clientTable[i = client->index].resources =
|
||||||
malloc(INITBUCKETS * sizeof(ResourcePtr));
|
calloc(INITBUCKETS, sizeof(ResourcePtr));
|
||||||
if (!clientTable[i].resources)
|
if (!clientTable[i].resources)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
clientTable[i].buckets = INITBUCKETS;
|
clientTable[i].buckets = INITBUCKETS;
|
||||||
|
@ -809,7 +809,7 @@ AddResource(XID id, RESTYPE type, void *value)
|
||||||
{
|
{
|
||||||
int client;
|
int client;
|
||||||
ClientResourceRec *rrec;
|
ClientResourceRec *rrec;
|
||||||
ResourcePtr res, *head;
|
ResourcePtr *head;
|
||||||
|
|
||||||
#ifdef XSERVER_DTRACE
|
#ifdef XSERVER_DTRACE
|
||||||
XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type));
|
XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type));
|
||||||
|
@ -824,7 +824,7 @@ AddResource(XID id, RESTYPE type, void *value)
|
||||||
if ((rrec->elements >= 4 * rrec->buckets) && (rrec->hashsize < MAXHASHSIZE))
|
if ((rrec->elements >= 4 * rrec->buckets) && (rrec->hashsize < MAXHASHSIZE))
|
||||||
RebuildTable(client);
|
RebuildTable(client);
|
||||||
head = &rrec->resources[HashResourceID(id, clientTable[client].hashsize)];
|
head = &rrec->resources[HashResourceID(id, clientTable[client].hashsize)];
|
||||||
res = malloc(sizeof(ResourceRec));
|
ResourcePtr res = calloc(1, sizeof(ResourceRec));
|
||||||
if (!res) {
|
if (!res) {
|
||||||
(*resourceTypes[type & TypeMask].deleteFunc) (value, id);
|
(*resourceTypes[type & TypeMask].deleteFunc) (value, id);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -94,7 +94,7 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
|
||||||
CARD32 tmpbuf[1];
|
CARD32 tmpbuf[1];
|
||||||
|
|
||||||
/* Allocate as big a buffer as we can... */
|
/* Allocate as big a buffer as we can... */
|
||||||
while (!(pbufT = malloc(bufsize))) {
|
while (!(pbufT = calloc(1, bufsize))) {
|
||||||
bufsize >>= 1;
|
bufsize >>= 1;
|
||||||
if (bufsize == 4) {
|
if (bufsize == 4) {
|
||||||
pbufT = tmpbuf;
|
pbufT = tmpbuf;
|
||||||
|
@ -141,7 +141,7 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
|
||||||
short tmpbuf[2];
|
short tmpbuf[2];
|
||||||
|
|
||||||
/* Allocate as big a buffer as we can... */
|
/* Allocate as big a buffer as we can... */
|
||||||
while (!(pbufT = malloc(bufsize))) {
|
while (!(pbufT = calloc(1, bufsize))) {
|
||||||
bufsize >>= 1;
|
bufsize >>= 1;
|
||||||
if (bufsize == 4) {
|
if (bufsize == 4) {
|
||||||
pbufT = tmpbuf;
|
pbufT = tmpbuf;
|
||||||
|
@ -1130,9 +1130,7 @@ SwapConnSetupInfo(char *pInfo, char *pInfoT)
|
||||||
void _X_COLD
|
void _X_COLD
|
||||||
WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
|
WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
|
||||||
{
|
{
|
||||||
char *pInfoTBase;
|
char *pInfoTBase = calloc(1, size);
|
||||||
|
|
||||||
pInfoTBase = malloc(size);
|
|
||||||
if (!pInfoTBase) {
|
if (!pInfoTBase) {
|
||||||
pClient->noClientException = -1;
|
pClient->noClientException = -1;
|
||||||
return;
|
return;
|
||||||
|
|
11
dix/window.c
11
dix/window.c
|
@ -581,7 +581,7 @@ CreateRootWindow(ScreenPtr pScreen)
|
||||||
pWin->parent = NullWindow;
|
pWin->parent = NullWindow;
|
||||||
SetWindowToDefaults(pWin);
|
SetWindowToDefaults(pWin);
|
||||||
|
|
||||||
pWin->optional = malloc(sizeof(WindowOptRec));
|
pWin->optional = calloc(1, sizeof(WindowOptRec));
|
||||||
if (!pWin->optional)
|
if (!pWin->optional)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -3197,7 +3197,6 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
|
||||||
Mask mask;
|
Mask mask;
|
||||||
WindowPtr pWin;
|
WindowPtr pWin;
|
||||||
CursorMetricRec cm;
|
CursorMetricRec cm;
|
||||||
unsigned char *srcbits, *mskbits;
|
|
||||||
CursorPtr cursor;
|
CursorPtr cursor;
|
||||||
XID cursorID = 0;
|
XID cursorID = 0;
|
||||||
int attri;
|
int attri;
|
||||||
|
@ -3235,8 +3234,8 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
|
||||||
cm.height = 16;
|
cm.height = 16;
|
||||||
cm.xhot = 8;
|
cm.xhot = 8;
|
||||||
cm.yhot = 8;
|
cm.yhot = 8;
|
||||||
srcbits = malloc(BitmapBytePad(32) * 16);
|
unsigned char *srcbits = calloc(16, BitmapBytePad(32));
|
||||||
mskbits = malloc(BitmapBytePad(32) * 16);
|
unsigned char *mskbits = calloc(16, BitmapBytePad(32));
|
||||||
if (!srcbits || !mskbits) {
|
if (!srcbits || !mskbits) {
|
||||||
free(srcbits);
|
free(srcbits);
|
||||||
free(mskbits);
|
free(mskbits);
|
||||||
|
@ -3374,12 +3373,12 @@ CheckWindowOptionalNeed(WindowPtr w)
|
||||||
Bool
|
Bool
|
||||||
MakeWindowOptional(WindowPtr pWin)
|
MakeWindowOptional(WindowPtr pWin)
|
||||||
{
|
{
|
||||||
WindowOptPtr optional;
|
|
||||||
WindowOptPtr parentOptional;
|
WindowOptPtr parentOptional;
|
||||||
|
|
||||||
if (pWin->optional)
|
if (pWin->optional)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
optional = malloc(sizeof(WindowOptRec));
|
|
||||||
|
WindowOptPtr optional = calloc(1, sizeof(WindowOptRec));
|
||||||
if (!optional)
|
if (!optional)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
|
optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
|
||||||
|
|
Loading…
Reference in New Issue