Compare commits

...

26 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult b5f508dd52 xwayland: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 3ab983fcc9 xwin: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 216bcc0ff9 xnest: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 2ad73189b4 xfree86: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 419076ae25 vfb: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 55032e9d19 kdrive: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 5a6a6754b8 include: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult 74b2b97be8 os: 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult aa43529bc2 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>
2025-05-22 18:59:05 +02:00
Enrico Weigelt, metux IT consult a87fa30ed5 render: 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>
2025-05-22 18:59:04 +02:00
Enrico Weigelt, metux IT consult 67fc0c527c randr: 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>
2025-05-22 18:59:04 +02:00
Enrico Weigelt, metux IT consult d827f6ab9a record: 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>
2025-05-22 18:59:04 +02:00
Enrico Weigelt, metux IT consult 9ebc53d776 miext: 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>
2025-05-22 18:59:04 +02:00
Enrico Weigelt, metux IT consult bde5962da4 glamor: 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>
2025-05-22 18:59:04 +02:00
Enrico Weigelt, metux IT consult 6b451da19c mi: 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>
2025-05-22 18:59:03 +02:00
Enrico Weigelt, metux IT consult 46a32f327e Xi: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult a4fb34d754 glx: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult 9d3dcea6ae dbe: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult 0111bd0d06 exa: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult ccf25f25c0 composite: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult fb3bbd5ec1 fb: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult 9acd7c0629 damageext: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult 1dd6363162 Xext: 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>
2025-05-22 18:58:08 +02:00
Enrico Weigelt, metux IT consult 85453198b6 test: 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>
2025-05-22 18:58:07 +02:00
Enrico Weigelt, metux IT consult c4740b57e6 xfixes: 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>
2025-05-22 18:58:07 +02:00
Enrico Weigelt, metux IT consult 76c98cb195 xkb: 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>
2025-05-22 18:58:07 +02:00
173 changed files with 464 additions and 646 deletions

View File

@ -145,10 +145,9 @@ ProcDPMSSelectInput(register ClientPtr client)
} }
/* build the entry */ /* build the entry */
pNewEvent = (DPMSEventPtr)malloc(sizeof(DPMSEventRec)); pNewEvent = calloc(1, sizeof(DPMSEventRec));
if (!pNewEvent) if (!pNewEvent)
return BadAlloc; return BadAlloc;
pNewEvent->next = 0;
pNewEvent->client = client; pNewEvent->client = client;
pNewEvent->mask = stuff->eventMask; pNewEvent->mask = stuff->eventMask;
/* /*
@ -164,7 +163,7 @@ ProcDPMSSelectInput(register ClientPtr client)
* of clients selecting input * of clients selecting input
*/ */
if (i != Success || !pHead) { if (i != Success || !pHead) {
pHead = (DPMSEventPtr *)malloc(sizeof(DPMSEventPtr)); pHead = calloc(1, sizeof(DPMSEventPtr));
if (!pHead || if (!pHead ||
!AddResource(eventResource, DPMSEventType, (void *)pHead)) { !AddResource(eventResource, DPMSEventType, (void *)pHead)) {
FreeResource(clientResource, X11_RESTYPE_NONE); FreeResource(clientResource, X11_RESTYPE_NONE);

View File

@ -39,7 +39,7 @@ ht_create(int keySize,
{ {
int c; int c;
int numBuckets; int numBuckets;
HashTable ht = malloc(sizeof(struct HashTableRec)); HashTable ht = calloc(1, sizeof(struct HashTableRec));
if (!ht) { if (!ht) {
return NULL; return NULL;
@ -127,7 +127,7 @@ ht_add(HashTable ht, const void *key)
if (!elem) { if (!elem) {
goto outOfMemory; goto outOfMemory;
} }
elem->key = malloc(ht->keySize); elem->key = calloc(1, ht->keySize);
if (!elem->key) { if (!elem->key) {
goto outOfMemory; goto outOfMemory;
} }

View File

@ -368,7 +368,7 @@ XineramaRegisterConnectionBlockCallback(void (*func) (void))
{ {
XineramaConnectionCallbackList *newlist; XineramaConnectionCallbackList *newlist;
if (!(newlist = malloc(sizeof(XineramaConnectionCallbackList)))) if (!(newlist = calloc(1, sizeof(XineramaConnectionCallbackList))))
return FALSE; return FALSE;
newlist->next = ConnectionCallbackList; newlist->next = ConnectionCallbackList;
@ -439,7 +439,6 @@ PanoramiXExtensionInit(void)
Bool success = FALSE; Bool success = FALSE;
ExtensionEntry *extEntry; ExtensionEntry *extEntry;
ScreenPtr pScreen = screenInfo.screens[0]; ScreenPtr pScreen = screenInfo.screens[0];
PanoramiXScreenPtr pScreenPriv;
if (noPanoramiXExtension) if (noPanoramiXExtension)
return; return;
@ -476,7 +475,7 @@ PanoramiXExtensionInit(void)
FOR_NSCREENS(i) { FOR_NSCREENS(i) {
pScreen = screenInfo.screens[i]; pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); PanoramiXScreenPtr pScreenPriv = calloc(1, sizeof(PanoramiXScreenRec));
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
pScreenPriv); pScreenPriv);
if (!pScreenPriv) { if (!pScreenPriv) {
@ -806,7 +805,6 @@ extern void
PanoramiXConsolidate(void) PanoramiXConsolidate(void)
{ {
int i; int i;
PanoramiXRes *root, *defmap, *saver;
ScreenPtr pScreen = screenInfo.screens[0]; ScreenPtr pScreen = screenInfo.screens[0];
DepthPtr pDepth = pScreen->allowedDepths; DepthPtr pDepth = pScreen->allowedDepths;
VisualPtr pVisual = pScreen->visuals; VisualPtr pVisual = pScreen->visuals;
@ -820,11 +818,11 @@ PanoramiXConsolidate(void)
for (i = 0; i < pScreen->numVisuals; i++) for (i = 0; i < pScreen->numVisuals; i++)
PanoramiXMaybeAddVisual(pVisual++); PanoramiXMaybeAddVisual(pVisual++);
root = malloc(sizeof(PanoramiXRes)); PanoramiXRes *root = calloc(1, sizeof(PanoramiXRes));
root->type = XRT_WINDOW; root->type = XRT_WINDOW;
defmap = malloc(sizeof(PanoramiXRes)); PanoramiXRes *defmap = calloc(1, sizeof(PanoramiXRes));
defmap->type = XRT_COLORMAP; defmap->type = XRT_COLORMAP;
saver = malloc(sizeof(PanoramiXRes)); PanoramiXRes *saver = calloc(1, sizeof(PanoramiXRes));
saver->type = XRT_WINDOW; saver->type = XRT_WINDOW;
FOR_NSCREENS(i) { FOR_NSCREENS(i) {

View File

@ -117,7 +117,7 @@ PanoramiXCreateWindow(ClientPtr client)
} }
} }
if (!(newWin = malloc(sizeof(PanoramiXRes)))) if (!(newWin = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newWin->type = XRT_WINDOW; newWin->type = XRT_WINDOW;
@ -694,7 +694,7 @@ PanoramiXCreatePixmap(ClientPtr client)
if (result != Success) if (result != Success)
return (result == BadValue) ? BadDrawable : result; return (result == BadValue) ? BadDrawable : result;
if (!(newPix = malloc(sizeof(PanoramiXRes)))) if (!(newPix = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPix->type = XRT_PIXMAP; newPix->type = XRT_PIXMAP;
@ -801,7 +801,7 @@ PanoramiXCreateGC(ClientPtr client)
} }
} }
if (!(newGC = malloc(sizeof(PanoramiXRes)))) if (!(newGC = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newGC->type = XRT_GC; newGC->type = XRT_GC;
@ -2289,7 +2289,7 @@ PanoramiXCreateColormap(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
if (!(newCmap = malloc(sizeof(PanoramiXRes)))) if (!(newCmap = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newCmap->type = XRT_COLORMAP; newCmap->type = XRT_COLORMAP;
@ -2361,7 +2361,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
if (!(newCmap = malloc(sizeof(PanoramiXRes)))) if (!(newCmap = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newCmap->type = XRT_COLORMAP; newCmap->type = XRT_COLORMAP;

View File

@ -1217,7 +1217,7 @@ ProcScreenSaverSuspend(ClientPtr client)
* to the record, so the screensaver will be re-enabled and the record freed * to the record, so the screensaver will be re-enabled and the record freed
* if the client disconnects without reenabling it first. * if the client disconnects without reenabling it first.
*/ */
this = malloc(sizeof(ScreenSaverSuspensionRec)); this = calloc(1, sizeof(ScreenSaverSuspensionRec));
if (!this) if (!this)
return BadAlloc; return BadAlloc;

View File

@ -385,7 +385,7 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
} }
} }
pEventClient = malloc(sizeof(OtherClients)); pEventClient = calloc(1, sizeof(OtherClients));
if (!pEventClient) if (!pEventClient)
return BadAlloc; return BadAlloc;
pEventClient->mask = mask; pEventClient->mask = mask;
@ -406,7 +406,6 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
REQUEST(xSecurityGenerateAuthorizationReq); REQUEST(xSecurityGenerateAuthorizationReq);
int len; /* request length in CARD32s */ int len; /* request length in CARD32s */
Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */ Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */
int err; /* error to return from this function */ int err; /* error to return from this function */
XID authId; /* authorization ID assigned by os layer */ XID authId; /* authorization ID assigned by os layer */
xSecurityGenerateAuthorizationReply rep; /* reply struct */ xSecurityGenerateAuthorizationReply rep; /* reply struct */
@ -493,8 +492,7 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
stuff->nbytesAuthData, protodata, stuff->nbytesAuthData, protodata,
&authdata_len, &pAuthdata); &authdata_len, &pAuthdata);
if ((XID) ~0L == authId) { if ((XID) ~0L == authId) {
err = SecurityErrorBase + XSecurityBadAuthorizationProtocol; return SecurityErrorBase + XSecurityBadAuthorizationProtocol;
goto bailout;
} }
/* now that we've added the auth, remember to remove it if we have to /* now that we've added the auth, remember to remove it if we have to
@ -504,7 +502,7 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* associate additional information with this auth ID */ /* associate additional information with this auth ID */
pAuth = malloc(sizeof(SecurityAuthorizationRec)); SecurityAuthorizationPtr pAuth = calloc(1, sizeof(SecurityAuthorizationRec));
if (!pAuth) { if (!pAuth) {
err = BadAlloc; err = BadAlloc;
goto bailout; goto bailout;

View File

@ -752,7 +752,7 @@ ProcShapeSelectInput(ClientPtr client)
} }
/* build the entry */ /* build the entry */
pNewShapeEvent = malloc(sizeof(ShapeEventRec)); pNewShapeEvent = calloc(1, sizeof(ShapeEventRec));
if (!pNewShapeEvent) if (!pNewShapeEvent)
return BadAlloc; return BadAlloc;
pNewShapeEvent->next = 0; pNewShapeEvent->next = 0;
@ -773,7 +773,7 @@ ProcShapeSelectInput(ClientPtr client)
* done through the resource database. * done through the resource database.
*/ */
if (!pHead) { if (!pHead) {
pHead = malloc(sizeof(ShapeEventPtr)); pHead = calloc(1, sizeof(ShapeEventPtr));
if (!pHead || if (!pHead ||
!AddResource(pWin->drawable.id, ShapeEventType, !AddResource(pWin->drawable.id, ShapeEventType,
(void *) pHead)) { (void *) pHead)) {
@ -962,7 +962,7 @@ ProcShapeGetRectangles(ClientPtr client)
} }
if (!region) { if (!region) {
nrects = 1; nrects = 1;
rects = malloc(sizeof(xRectangle)); rects = calloc(1, sizeof(xRectangle));
if (!rects) if (!rects)
return BadAlloc; return BadAlloc;
switch (stuff->kind) { switch (stuff->kind) {

View File

@ -395,7 +395,7 @@ ProcShmAttach(ClientPtr client)
shmdesc->refcnt++; shmdesc->refcnt++;
} }
else { else {
shmdesc = malloc(sizeof(ShmDescRec)); shmdesc = calloc(1, sizeof(ShmDescRec));
if (!shmdesc) if (!shmdesc)
return BadAlloc; return BadAlloc;
#ifdef SHM_FD_PASSING #ifdef SHM_FD_PASSING
@ -781,7 +781,6 @@ static int
ProcPanoramiXShmGetImage(ClientPtr client) ProcPanoramiXShmGetImage(ClientPtr client)
{ {
PanoramiXRes *draw; PanoramiXRes *draw;
DrawablePtr *drawables;
DrawablePtr pDraw; DrawablePtr pDraw;
xShmGetImageReply xgi; xShmGetImageReply xgi;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
@ -856,7 +855,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr)); DrawablePtr *drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr));
if (!drawables) if (!drawables)
return BadAlloc; return BadAlloc;
@ -976,7 +975,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
if (!(newPix = malloc(sizeof(PanoramiXRes)))) if (!(newPix = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPix->type = XRT_PIXMAP; newPix->type = XRT_PIXMAP;
@ -1169,7 +1168,7 @@ ProcShmAttachFd(ClientPtr client)
return BadMatch; return BadMatch;
} }
shmdesc = malloc(sizeof(ShmDescRec)); shmdesc = calloc(1, sizeof(ShmDescRec));
if (!shmdesc) { if (!shmdesc) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;
@ -1286,7 +1285,7 @@ ProcShmCreateSegment(ClientPtr client)
close(fd); close(fd);
return BadAlloc; return BadAlloc;
} }
shmdesc = malloc(sizeof(ShmDescRec)); shmdesc = calloc(1, sizeof(ShmDescRec));
if (!shmdesc) { if (!shmdesc) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;

View File

@ -72,7 +72,7 @@ ClientSleepUntil(ClientPtr client,
TimeStamp *revive, TimeStamp *revive,
void (*notifyFunc) (ClientPtr, void *), void *closure) void (*notifyFunc) (ClientPtr, void *), void *closure)
{ {
SertafiedPtr pRequest, pReq, pPrev; SertafiedPtr pReq, pPrev;
if (SertafiedGeneration != serverGeneration) { if (SertafiedGeneration != serverGeneration) {
SertafiedResType = CreateNewResourceType(SertafiedDelete, SertafiedResType = CreateNewResourceType(SertafiedDelete,
@ -82,7 +82,8 @@ ClientSleepUntil(ClientPtr client,
SertafiedGeneration = serverGeneration; SertafiedGeneration = serverGeneration;
BlockHandlerRegistered = FALSE; BlockHandlerRegistered = FALSE;
} }
pRequest = malloc(sizeof(SertafiedRec));
SertafiedPtr pRequest = calloc(1, sizeof(SertafiedRec));
if (!pRequest) if (!pRequest)
return FALSE; return FALSE;
pRequest->pClient = client; pRequest->pClient = client;

View File

@ -764,8 +764,6 @@ SyncChangeCounter(SyncCounter * pCounter, int64_t newval)
static Bool static Bool
SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents) SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
{ {
SyncAlarmClientList *pClients;
if (client == pAlarm->client) { /* alarm owner */ if (client == pAlarm->client) { /* alarm owner */
pAlarm->events = wantevents; pAlarm->events = wantevents;
return Success; return Success;
@ -773,7 +771,8 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
/* see if the client is already on the list (has events selected) */ /* see if the client is already on the list (has events selected) */
for (pClients = pAlarm->pEventClients; pClients; pClients = pClients->next) { for (SyncAlarmClientList *pClients = pClients = pAlarm->pEventClients;
pClients; pClients = pClients->next) {
if (pClients->client == client) { if (pClients->client == client) {
/* client's presence on the list indicates desire for /* client's presence on the list indicates desire for
* events. If the client doesn't want events, remove it * events. If the client doesn't want events, remove it
@ -799,7 +798,7 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
/* add new client to pAlarm->pEventClients */ /* add new client to pAlarm->pEventClients */
pClients = malloc(sizeof(SyncAlarmClientList)); SyncAlarmClientList *pClients = calloc(1, sizeof(SyncAlarmClientList));
if (!pClients) if (!pClients)
return BadAlloc; return BadAlloc;
@ -934,7 +933,7 @@ SyncCreate(ClientPtr client, XID id, unsigned char type)
switch (type) { switch (type) {
case SYNC_COUNTER: case SYNC_COUNTER:
pSync = malloc(sizeof(SyncCounter)); pSync = calloc(1, sizeof(SyncCounter));
resType = RTCounter; resType = RTCounter;
break; break;
case SYNC_FENCE: case SYNC_FENCE:
@ -1030,9 +1029,7 @@ SyncCreateSystemCounter(const char *name,
SyncCounter *pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial); SyncCounter *pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
if (pCounter) { if (pCounter) {
SysCounterInfo *psci; SysCounterInfo *psci = calloc(1, sizeof(SysCounterInfo));
psci = malloc(sizeof(SysCounterInfo));
if (!psci) { if (!psci) {
FreeResource(pCounter->sync.id, X11_RESTYPE_NONE); FreeResource(pCounter->sync.id, X11_RESTYPE_NONE);
return pCounter; return pCounter;
@ -1311,7 +1308,7 @@ ProcSyncListSystemCounters(ClientPtr client)
} }
if (len) { if (len) {
walklist = list = malloc(len); walklist = list = calloc(1, len);
if (!list) if (!list)
return BadAlloc; return BadAlloc;
} }
@ -1739,7 +1736,7 @@ ProcSyncCreateAlarm(ClientPtr client)
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue | XSyncCADelta)))) if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue | XSyncCADelta))))
return BadLength; return BadLength;
if (!(pAlarm = malloc(sizeof(SyncAlarm)))) { if (!(pAlarm = calloc(1, sizeof(SyncAlarm)))) {
return BadAlloc; return BadAlloc;
} }
@ -2824,7 +2821,7 @@ init_system_idle_counter(const char *name, int deviceid)
IdleTimeBracketValues); IdleTimeBracketValues);
if (idle_time_counter != NULL) { if (idle_time_counter != NULL) {
IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv)); IdleCounterPriv *priv = calloc(1, sizeof(IdleCounterPriv));
priv->value_less = priv->value_greater = NULL; priv->value_less = priv->value_greater = NULL;
priv->deviceid = deviceid; priv->deviceid = deviceid;

View File

@ -75,9 +75,7 @@ typedef struct {
static DisplayModePtr static DisplayModePtr
VidModeCreateMode(void) VidModeCreateMode(void)
{ {
DisplayModePtr mode; DisplayModePtr mode = calloc(1, sizeof(DisplayModeRec));
mode = malloc(sizeof(DisplayModeRec));
if (mode != NULL) { if (mode != NULL) {
mode->name = ""; mode->name = "";
mode->VScan = 1; /* divides refresh rate. default = 1 */ mode->VScan = 1; /* divides refresh rate. default = 1 */
@ -1630,7 +1628,7 @@ ProcVidModeSetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
if ((pPriv = VM_GETPRIV(client)) == NULL) { if ((pPriv = VM_GETPRIV(client)) == NULL) {
pPriv = malloc(sizeof(VidModePrivRec)); pPriv = calloc(1, sizeof(VidModePrivRec));
if (!pPriv) if (!pPriv)
return BadAlloc; return BadAlloc;
VM_SETPRIV(client, pPriv); VM_SETPRIV(client, pPriv);

View File

@ -204,7 +204,6 @@ XaceCensorImage(ClientPtr client,
if (nRects > 0) { /* we have something to censor */ if (nRects > 0) { /* we have something to censor */
GCPtr pScratchGC = NULL; GCPtr pScratchGC = NULL;
PixmapPtr pPix = NULL; PixmapPtr pPix = NULL;
xRectangle *pRects = NULL;
Bool failed = FALSE; Bool failed = FALSE;
int depth = 1; int depth = 1;
int bitsPerPixel = 1; int bitsPerPixel = 1;
@ -213,7 +212,7 @@ XaceCensorImage(ClientPtr client,
/* convert region to list-of-rectangles for PolyFillRect */ /* convert region to list-of-rectangles for PolyFillRect */
pRects = malloc(nRects * sizeof(xRectangle)); xRectangle *pRects = calloc(1, nRects * sizeof(xRectangle));
if (!pRects) { if (!pRects) {
failed = TRUE; failed = TRUE;
goto failSafe; goto failSafe;

View File

@ -147,7 +147,6 @@ static ShmDescPtr ShmList = (ShmDescPtr) NULL;
static ShmDescPtr static ShmDescPtr
shmalloc(unsigned int size) shmalloc(unsigned int size)
{ {
ShmDescPtr pDesc;
int shmid; int shmid;
char *addr; char *addr;
@ -165,7 +164,7 @@ shmalloc(unsigned int size)
if (size < 3500) if (size < 3500)
return (ShmDescPtr) NULL; return (ShmDescPtr) NULL;
pDesc = malloc(sizeof(ShmDescRec)); ShmDescPtr pDesc = calloc(1, sizeof(ShmDescRec));
if (!pDesc) if (!pDesc)
return (ShmDescPtr) NULL; return (ShmDescPtr) NULL;

View File

@ -103,7 +103,7 @@ typedef struct {
static void * static void *
AddFragment(struct xorg_list *frags, int bytes) AddFragment(struct xorg_list *frags, int bytes)
{ {
FragmentList *f = malloc(sizeof(FragmentList) + bytes); FragmentList *f = calloc(1, sizeof(FragmentList) + bytes);
if (!f) { if (!f) {
return NULL; return NULL;
} else { } else {

View File

@ -55,7 +55,7 @@ int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
static char * static char *
SELinuxCopyContext(char *ptr, unsigned len) SELinuxCopyContext(char *ptr, unsigned len)
{ {
char *copy = malloc(len + 1); char *copy = calloc(1, len + 1);
if (!copy) if (!copy)
return NULL; return NULL;

View File

@ -992,7 +992,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
num_planes = pImage->num_planes; num_planes = pImage->num_planes;
if (!(offsets = malloc(num_planes << 3))) if (!(offsets = calloc(1, num_planes << 3)))
return BadAlloc; return BadAlloc;
pitches = offsets + num_planes; pitches = offsets + num_planes;
@ -1745,7 +1745,7 @@ XineramifyXv(void)
/* now create a resource for each port */ /* now create a resource for each port */
for (j = 0; j < refAdapt->nPorts; j++) { for (j = 0; j < refAdapt->nPorts; j++) {
PanoramiXRes *port = malloc(sizeof(PanoramiXRes)); PanoramiXRes *port = calloc(1, sizeof(PanoramiXRes));
if (!port) if (!port)
break; break;

View File

@ -260,8 +260,6 @@ CreateResourceTypes(void)
int int
XvScreenInit(ScreenPtr pScreen) XvScreenInit(ScreenPtr pScreen)
{ {
XvScreenPtr pxvs;
if (XvScreenGeneration != serverGeneration) { if (XvScreenGeneration != serverGeneration) {
if (!CreateResourceTypes()) { if (!CreateResourceTypes()) {
ErrorF("XvScreenInit: Unable to allocate resource types\n"); ErrorF("XvScreenInit: Unable to allocate resource types\n");
@ -282,7 +280,7 @@ XvScreenInit(ScreenPtr pScreen)
/* ALLOCATE SCREEN PRIVATE RECORD */ /* ALLOCATE SCREEN PRIVATE RECORD */
pxvs = malloc(sizeof(XvScreenRec)); XvScreenPtr pxvs = calloc(1, sizeof(XvScreenRec));
if (!pxvs) { if (!pxvs) {
ErrorF("XvScreenInit: Unable to allocate screen private structure\n"); ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
return BadAlloc; return BadAlloc;
@ -809,7 +807,7 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */ WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */
if (!pn) { if (!pn) {
if (!(tpn = malloc(sizeof(XvVideoNotifyRec)))) if (!(tpn = calloc(1, sizeof(XvVideoNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = NULL; tpn->next = NULL;
tpn->client = NULL; tpn->client = NULL;
@ -845,7 +843,7 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
tpn = fpn; tpn = fpn;
} }
else { else {
if (!(tpn = malloc(sizeof(XvVideoNotifyRec)))) if (!(tpn = calloc(1, sizeof(XvVideoNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = pn->next; tpn->next = pn->next;
pn->next = tpn; pn->next = tpn;
@ -899,7 +897,7 @@ XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff)
CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */ CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
if (!tpn) { if (!tpn) {
if (!(tpn = malloc(sizeof(XvPortNotifyRec)))) if (!(tpn = calloc(1, sizeof(XvPortNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = pPort->pNotify; tpn->next = pPort->pNotify;
pPort->pNotify = tpn; pPort->pNotify = tpn;

View File

@ -233,7 +233,7 @@ ProcXvMCCreateContext(ClientPtr client)
(stuff->height > surface->max_height)) (stuff->height > surface->max_height))
return BadValue; return BadValue;
if (!(pContext = malloc(sizeof(XvMCContextRec)))) { if (!(pContext = calloc(1, sizeof(XvMCContextRec)))) {
return BadAlloc; return BadAlloc;
} }
@ -315,7 +315,7 @@ ProcXvMCCreateSurface(ClientPtr client)
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
if (!(pSurface = malloc(sizeof(XvMCSurfaceRec)))) if (!(pSurface = calloc(1, sizeof(XvMCSurfaceRec))))
return BadAlloc; return BadAlloc;
pSurface->surface_id = stuff->surface_id; pSurface->surface_id = stuff->surface_id;
@ -428,7 +428,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
(stuff->height > surface->subpicture_max_height)) (stuff->height > surface->subpicture_max_height))
return BadValue; return BadValue;
if (!(pSubpicture = malloc(sizeof(XvMCSubpictureRec)))) if (!(pSubpicture = calloc(1, sizeof(XvMCSubpictureRec))))
return BadAlloc; return BadAlloc;
pSubpicture->subpicture_id = stuff->subpicture_id; pSubpicture->subpicture_id = stuff->subpicture_id;
@ -753,7 +753,7 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc; return BadAlloc;
if (!(pScreenPriv = malloc(sizeof(XvMCScreenRec)))) if (!(pScreenPriv = calloc(1, sizeof(XvMCScreenRec))))
return BadAlloc; return BadAlloc;
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);

View File

@ -2330,12 +2330,10 @@ DeliverGestureEventToOwner(DeviceIntPtr dev, GestureInfoPtr gi, InternalEvent *e
int int
InitProximityClassDeviceStruct(DeviceIntPtr dev) InitProximityClassDeviceStruct(DeviceIntPtr dev)
{ {
ProximityClassPtr proxc;
BUG_RETURN_VAL(dev == NULL, FALSE); BUG_RETURN_VAL(dev == NULL, FALSE);
BUG_RETURN_VAL(dev->proximity != NULL, FALSE); BUG_RETURN_VAL(dev->proximity != NULL, FALSE);
proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec)); ProximityClassPtr proxc = calloc(1, sizeof(ProximityClassRec));
if (!proxc) if (!proxc)
return FALSE; return FALSE;
proxc->sourceid = dev->id; proxc->sourceid = dev->id;

View File

@ -168,7 +168,7 @@ int
ProcXGetDeviceControl(ClientPtr client) ProcXGetDeviceControl(ClientPtr client)
{ {
int rc, total_length = 0; int rc, total_length = 0;
char *buf, *savbuf; char *savbuf;
DeviceIntPtr dev; DeviceIntPtr dev;
xGetDeviceControlReply rep; xGetDeviceControlReply rep;
@ -206,7 +206,7 @@ ProcXGetDeviceControl(ClientPtr client)
return BadValue; return BadValue;
} }
buf = (char *) malloc(total_length); char *buf = calloc(1, total_length);
if (!buf) if (!buf)
return BadAlloc; return BadAlloc;
savbuf = buf; savbuf = buf;

View File

@ -261,7 +261,7 @@ int
ProcXGetFeedbackControl(ClientPtr client) ProcXGetFeedbackControl(ClientPtr client)
{ {
int rc, total_length = 0; int rc, total_length = 0;
char *buf, *savbuf; char *savbuf;
DeviceIntPtr dev; DeviceIntPtr dev;
KbdFeedbackPtr k; KbdFeedbackPtr k;
PtrFeedbackPtr p; PtrFeedbackPtr p;
@ -315,7 +315,7 @@ ProcXGetFeedbackControl(ClientPtr client)
if (total_length == 0) if (total_length == 0)
return BadMatch; return BadMatch;
buf = (char *) malloc(total_length); char *buf = (char *) calloc(1, total_length);
if (!buf) if (!buf)
return BadAlloc; return BadAlloc;
savbuf = buf; savbuf = buf;

View File

@ -131,7 +131,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
total_length = (rep.all_clients_count + rep.this_client_count) * total_length = (rep.all_clients_count + rep.this_client_count) *
sizeof(XEventClass); sizeof(XEventClass);
rep.length = bytes_to_int32(total_length); rep.length = bytes_to_int32(total_length);
buf = (XEventClass *) malloc(total_length); buf = calloc(1, total_length);
tclient = buf; tclient = buf;
aclient = buf + rep.this_client_count; aclient = buf + rep.this_client_count;

View File

@ -104,9 +104,7 @@ typedef struct _BarrierScreen {
static struct PointerBarrierDevice *AllocBarrierDevice(void) static struct PointerBarrierDevice *AllocBarrierDevice(void)
{ {
struct PointerBarrierDevice *pbd = NULL; struct PointerBarrierDevice *pbd = calloc(1, sizeof(struct PointerBarrierDevice));
pbd = malloc(sizeof(struct PointerBarrierDevice));
if (!pbd) if (!pbd)
return NULL; return NULL;
@ -557,15 +555,13 @@ CreatePointerBarrierClient(ClientPtr client,
ScreenPtr screen; ScreenPtr screen;
BarrierScreenPtr cs; BarrierScreenPtr cs;
int err; int err;
int size;
int i; int i;
struct PointerBarrierClient *ret;
CARD16 *in_devices; CARD16 *in_devices;
DeviceIntPtr dev; DeviceIntPtr dev;
size = sizeof(*ret) + sizeof(DeviceIntPtr) * stuff->num_devices; const int size = sizeof(struct PointerBarrierClient)
ret = malloc(size); + sizeof(DeviceIntPtr) * stuff->num_devices;
struct PointerBarrierClient *ret = calloc(1, size);
if (!ret) { if (!ret) {
return BadAlloc; return BadAlloc;
} }

View File

@ -575,9 +575,7 @@ XIUnregisterPropertyHandler(DeviceIntPtr dev, long id)
static XIPropertyPtr static XIPropertyPtr
XICreateDeviceProperty(Atom property) XICreateDeviceProperty(Atom property)
{ {
XIPropertyPtr prop; XIPropertyPtr prop = calloc(1, sizeof(XIPropertyRec));
prop = (XIPropertyPtr) malloc(sizeof(XIPropertyRec));
if (!prop) if (!prop)
return NULL; return NULL;

View File

@ -134,7 +134,6 @@ int
compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
{ {
CompWindowPtr cw = GetCompWindow(pWin); CompWindowPtr cw = GetCompWindow(pWin);
CompClientWindowPtr ccw;
CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen); CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
WindowPtr pLayerWin; WindowPtr pLayerWin;
Bool anyMarked = FALSE; Bool anyMarked = FALSE;
@ -151,7 +150,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
* Only one Manual update is allowed * Only one Manual update is allowed
*/ */
if (cw && update == CompositeRedirectManual) if (cw && update == CompositeRedirectManual)
for (ccw = cw->clients; ccw; ccw = ccw->next) for (CompClientWindowPtr ccw = cw->clients; ccw; ccw = ccw->next)
if (ccw->update == CompositeRedirectManual) if (ccw->update == CompositeRedirectManual)
return BadAccess; return BadAccess;
@ -160,7 +159,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
* The client *could* allocate multiple, but while supported, * The client *could* allocate multiple, but while supported,
* it is not expected to be common * it is not expected to be common
*/ */
ccw = malloc(sizeof(CompClientWindowRec)); CompClientWindowPtr ccw = calloc(1, sizeof(CompClientWindowRec));
if (!ccw) if (!ccw)
return BadAlloc; return BadAlloc;
ccw->id = FakeClientID(pClient->index); ccw->id = FakeClientID(pClient->index);
@ -169,7 +168,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
* Now make sure there's a per-window structure to hang this from * Now make sure there's a per-window structure to hang this from
*/ */
if (!cw) { if (!cw) {
cw = malloc(sizeof(CompWindowRec)); cw = calloc(1, sizeof(CompWindowRec));
if (!cw) { if (!cw) {
free(ccw); free(ccw);
return BadAlloc; return BadAlloc;
@ -342,14 +341,13 @@ int
compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update) compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
{ {
CompSubwindowsPtr csw = GetCompSubwindows(pWin); CompSubwindowsPtr csw = GetCompSubwindows(pWin);
CompClientWindowPtr ccw;
WindowPtr pChild; WindowPtr pChild;
/* /*
* Only one Manual update is allowed * Only one Manual update is allowed
*/ */
if (csw && update == CompositeRedirectManual) if (csw && update == CompositeRedirectManual)
for (ccw = csw->clients; ccw; ccw = ccw->next) for (CompClientWindowPtr ccw = csw->clients; ccw; ccw = ccw->next)
if (ccw->update == CompositeRedirectManual) if (ccw->update == CompositeRedirectManual)
return BadAccess; return BadAccess;
/* /*
@ -357,7 +355,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
* The client *could* allocate multiple, but while supported, * The client *could* allocate multiple, but while supported,
* it is not expected to be common * it is not expected to be common
*/ */
ccw = malloc(sizeof(CompClientWindowRec)); CompClientWindowPtr ccw = calloc(1, sizeof(CompClientWindowRec));
if (!ccw) if (!ccw)
return BadAlloc; return BadAlloc;
ccw->id = FakeClientID(pClient->index); ccw->id = FakeClientID(pClient->index);
@ -366,7 +364,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
* Now make sure there's a per-window structure to hang this from * Now make sure there's a per-window structure to hang this from
*/ */
if (!csw) { if (!csw) {
csw = malloc(sizeof(CompSubwindowsRec)); csw = calloc(1, sizeof(CompSubwindowsRec));
if (!csw) { if (!csw) {
free(ccw); free(ccw);
return BadAlloc; return BadAlloc;

View File

@ -700,7 +700,7 @@ PanoramiXCompositeNameWindowPixmap(ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pixmap, client); LEGAL_NEW_RESOURCE(stuff->pixmap, client);
if (!(newPix = malloc(sizeof(PanoramiXRes)))) if (!(newPix = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPix->type = XRT_PIXMAP; newPix->type = XRT_PIXMAP;
@ -769,7 +769,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
cs = GetCompScreen(screenInfo.screens[0]); cs = GetCompScreen(screenInfo.screens[0]);
if (!cs->pOverlayWin) { if (!cs->pOverlayWin) {
if (!(overlayWin = malloc(sizeof(PanoramiXRes)))) if (!(overlayWin = calloc(1, sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
overlayWin->type = XRT_WINDOW; overlayWin->type = XRT_WINDOW;

View File

@ -334,8 +334,6 @@ compAddAlternateVisuals(ScreenPtr pScreen, CompScreenPtr cs)
Bool Bool
compScreenInit(ScreenPtr pScreen) compScreenInit(ScreenPtr pScreen)
{ {
CompScreenPtr cs;
if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
@ -345,7 +343,7 @@ compScreenInit(ScreenPtr pScreen)
if (GetCompScreen(pScreen)) if (GetCompScreen(pScreen))
return TRUE; return TRUE;
cs = (CompScreenPtr) malloc(sizeof(CompScreenRec)); CompScreenPtr cs = calloc(1, sizeof(CompScreenRec));
if (!cs) if (!cs)
return FALSE; return FALSE;

View File

@ -96,9 +96,7 @@ CompOverlayClientPtr
compCreateOverlayClient(ScreenPtr pScreen, ClientPtr pClient) compCreateOverlayClient(ScreenPtr pScreen, ClientPtr pClient)
{ {
CompScreenPtr cs = GetCompScreen(pScreen); CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc; CompOverlayClientPtr pOc = calloc(1, sizeof(CompOverlayClientRec));
pOc = (CompOverlayClientPtr) malloc(sizeof(CompOverlayClientRec));
if (pOc == NULL) if (pOc == NULL)
return NULL; return NULL;

View File

@ -233,7 +233,7 @@ static DamageExtPtr
DamageExtCreate(DrawablePtr pDrawable, DamageReportLevel level, DamageExtCreate(DrawablePtr pDrawable, DamageReportLevel level,
ClientPtr client, XID id, XID drawable) ClientPtr client, XID id, XID drawable)
{ {
DamageExtPtr pDamageExt = malloc(sizeof(DamageExtRec)); DamageExtPtr pDamageExt = calloc(1, sizeof(DamageExtRec));
if (!pDamageExt) if (!pDamageExt)
return NULL; return NULL;

View File

@ -1363,7 +1363,7 @@ DbeExtensionInit(void)
pScreen = screenInfo.screens[i]; pScreen = screenInfo.screens[i];
if (!(pDbeScreenPriv = malloc(sizeof(DbeScreenPrivRec)))) { if (!(pDbeScreenPriv = calloc(1, sizeof(DbeScreenPrivRec)))) {
/* If we can not alloc a window or screen private, /* If we can not alloc a window or screen private,
* then free any privates that we already alloc'ed and return * then free any privates that we already alloc'ed and return
*/ */

View File

@ -100,9 +100,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) {

View File

@ -266,7 +266,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)) {
@ -1087,9 +1087,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;
@ -1507,7 +1505,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;
} }
@ -1574,7 +1572,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;
} }
@ -1977,7 +1975,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);

View File

@ -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;

View File

@ -1203,7 +1203,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.
* *
@ -1476,12 +1476,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();
@ -1499,11 +1497,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;
@ -1542,11 +1538,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;
@ -1578,11 +1573,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;
@ -1599,11 +1592,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;
@ -1621,11 +1612,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;

View File

@ -643,7 +643,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;
@ -2574,7 +2574,6 @@ ProcUninstallColormap(ClientPtr client)
int int
ProcListInstalledColormaps(ClientPtr client) ProcListInstalledColormaps(ClientPtr client)
{ {
xListInstalledColormapsReply *preply;
int nummaps, rc; int nummaps, rc;
WindowPtr pWin; WindowPtr pWin;
@ -2589,7 +2588,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)
@ -2704,7 +2704,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) {
@ -2717,7 +2717,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;
@ -2766,7 +2766,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) {
@ -2784,7 +2783,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,
@ -2996,7 +2995,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;
@ -3044,7 +3042,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;

View File

@ -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;
@ -1411,7 +1410,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
@ -1419,7 +1417,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;
@ -1617,13 +1615,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;
@ -1730,7 +1727,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;

View File

@ -532,9 +532,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;
@ -566,9 +564,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;
@ -655,9 +651,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;
@ -777,12 +771,12 @@ _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;

View File

@ -1141,7 +1141,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;
@ -1202,7 +1201,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 @@ 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;

View File

@ -283,7 +283,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++) {

View File

@ -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);
@ -924,9 +920,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;
@ -1005,13 +1001,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;

View File

@ -433,7 +433,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;

View File

@ -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++)

View File

@ -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;

View File

@ -261,7 +261,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;
@ -277,7 +276,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);
@ -316,7 +315,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;
@ -331,7 +330,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);
@ -340,7 +339,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);

View File

@ -227,16 +227,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;
@ -348,7 +346,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;
@ -356,7 +354,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;
@ -1142,7 +1140,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 */
@ -1185,7 +1182,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;
@ -1316,7 +1313,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;
@ -1343,7 +1339,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;

View File

@ -649,13 +649,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;
@ -808,7 +808,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));
@ -823,7 +823,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;

View File

@ -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;

View File

@ -592,7 +592,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;
@ -3216,7 +3216,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;
@ -3254,8 +3253,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);
@ -3395,12 +3394,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];
@ -3491,12 +3490,11 @@ ChangeWindowDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev, CursorPtr pCursor)
} }
else { else {
/* no device cursor yet */ /* no device cursor yet */
DevCursNodePtr pNewNode;
if (!pCursor) if (!pCursor)
return Success; return Success;
pNewNode = malloc(sizeof(DevCursNodeRec)); DevCursNodePtr pNewNode = calloc(1, sizeof(DevCursNodeRec));
pNewNode->dev = pDev; pNewNode->dev = pDev;
pNewNode->next = pWin->optional->deviceCursors; pNewNode->next = pWin->optional->deviceCursors;
pWin->optional->deviceCursors = pNewNode; pWin->optional->deviceCursors = pNewNode;

View File

@ -96,7 +96,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
pExaPixmap->use_gpu_copy = FALSE; pExaPixmap->use_gpu_copy = FALSE;
if (w == 1 && h == 1) { if (w == 1 && h == 1) {
pExaPixmap->sys_ptr = malloc(paddedWidth); pExaPixmap->sys_ptr = calloc(1, paddedWidth);
/* Set up damage tracking */ /* Set up damage tracking */
pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL, pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,

View File

@ -238,7 +238,7 @@ exaOffscreenAlloc(ScreenPtr pScreen, int size, int align,
/* save extra space in new area */ /* save extra space in new area */
if (real_size < area->size) { if (real_size < area->size) {
ExaOffscreenArea *new_area = malloc(sizeof(ExaOffscreenArea)); ExaOffscreenArea *new_area = calloc(1, sizeof(ExaOffscreenArea));
if (!new_area) if (!new_area)
return NULL; return NULL;
@ -634,11 +634,9 @@ Bool
exaOffscreenInit(ScreenPtr pScreen) exaOffscreenInit(ScreenPtr pScreen)
{ {
ExaScreenPriv(pScreen); ExaScreenPriv(pScreen);
ExaOffscreenArea *area;
/* Allocate a big free area */ /* Allocate a big free area */
area = malloc(sizeof(ExaOffscreenArea)); ExaOffscreenArea *area = calloc(1, sizeof(ExaOffscreenArea));
if (!area) if (!area)
return FALSE; return FALSE;

View File

@ -273,7 +273,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
int nvisuals; int nvisuals;
int ndepths; int ndepths;
VisualID defaultVisual; VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
if (!dixRegisterPrivateKey if (!dixRegisterPrivateKey
(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) (&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
@ -282,7 +281,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
if (bpp1 == 24 || bpp2 == 24) if (bpp1 == 24 || bpp2 == 24)
return FALSE; return FALSE;
pScrPriv = malloc(sizeof(FbOverlayScrPrivRec)); FbOverlayScrPrivPtr pScrPriv = calloc(1, sizeof(FbOverlayScrPrivRec));
if (!pScrPriv) if (!pScrPriv)
return FALSE; return FALSE;

View File

@ -58,11 +58,10 @@ glamor_compile_glsl_prog(GLenum type, const char *source)
glCompileShader(prog); glCompileShader(prog);
glGetShaderiv(prog, GL_COMPILE_STATUS, &ok); glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
if (!ok) { if (!ok) {
GLchar *info;
GLint size; GLint size;
glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size); glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size); GLchar *info = calloc(1, size);
if (info) { if (info) {
glGetShaderInfoLog(prog, size, NULL, info); glGetShaderInfoLog(prog, size, NULL, info);
ErrorF("Failed to compile %s: %s\n", ErrorF("Failed to compile %s: %s\n",
@ -98,11 +97,10 @@ glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const char *format, ...)
glLinkProgram(prog); glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &ok); glGetProgramiv(prog, GL_LINK_STATUS, &ok);
if (!ok) { if (!ok) {
GLchar *info;
GLint size; GLint size;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size); glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size); GLchar *info = calloc(1, size);
glGetProgramInfoLog(prog, size, NULL, info); glGetProgramInfoLog(prog, size, NULL, info);
ErrorF("Failed to link: %s\n", info); ErrorF("Failed to link: %s\n", info);

View File

@ -51,7 +51,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
unsigned char c[2]; unsigned char c[2];
CharInfoPtr glyph; CharInfoPtr glyph;
unsigned long count; unsigned long count;
char *bits;
if (!glamor_glsl_has_ints(glamor_priv)) if (!glamor_glsl_has_ints(glamor_priv))
return NULL; return NULL;
@ -102,7 +101,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
/* fallback if we don't fit inside a texture */ /* fallback if we don't fit inside a texture */
return NULL; return NULL;
} }
bits = malloc(overall_width * overall_height); char *bits = calloc(overall_width, overall_height);
if (!bits) if (!bits)
return NULL; return NULL;

View File

@ -1171,7 +1171,7 @@ glamor_composite_largepixmap_region(CARD8 op,
&& glamor_pixmap_priv_is_large(source_pixmap_priv)) { && glamor_pixmap_priv_is_large(source_pixmap_priv)) {
/* XXX self-copy... */ /* XXX self-copy... */
need_free_source_pixmap_priv = source_pixmap_priv; need_free_source_pixmap_priv = source_pixmap_priv;
source_pixmap_priv = malloc(sizeof(*source_pixmap_priv)); source_pixmap_priv = calloc(1, sizeof(*source_pixmap_priv));
*source_pixmap_priv = *need_free_source_pixmap_priv; *source_pixmap_priv = *need_free_source_pixmap_priv;
need_free_source_pixmap_priv = source_pixmap_priv; need_free_source_pixmap_priv = source_pixmap_priv;
} }

View File

@ -272,15 +272,15 @@ __glXcombine_strings(const char *cext_string, const char *sext_string)
clen = strlen(cext_string); clen = strlen(cext_string);
slen = strlen(sext_string); slen = strlen(sext_string);
if (clen > slen) { if (clen > slen) {
combo_string = (char *) malloc(slen + 2); combo_string = (char *) calloc(1, slen + 2);
s1 = (char *) malloc(slen + 2); s1 = (char *) calloc(1, slen + 2);
if (s1) if (s1)
strcpy(s1, sext_string); strcpy(s1, sext_string);
s2 = cext_string; s2 = cext_string;
} }
else { else {
combo_string = (char *) malloc(clen + 2); combo_string = (char *) calloc(1, clen + 2);
s1 = (char *) malloc(clen + 2); s1 = (char *) calloc(1, clen + 2);
if (s1) if (s1)
strcpy(s1, cext_string); strcpy(s1, cext_string);
s2 = sext_string; s2 = sext_string;

View File

@ -126,7 +126,6 @@ static int dispatch_GLXQueryVersion(ClientPtr client)
static int dispatch_GLXClientInfo(ClientPtr client) static int dispatch_GLXClientInfo(ClientPtr client)
{ {
GlxServerVendor *vendor; GlxServerVendor *vendor;
void *requestCopy = NULL;
size_t requestSize = client->req_len * 4; size_t requestSize = client->req_len * 4;
if (client->minorOp == X_GLXClientInfo) { if (client->minorOp == X_GLXClientInfo) {
@ -142,7 +141,7 @@ static int dispatch_GLXClientInfo(ClientPtr client)
// We'll forward this request to each vendor library. Since a vendor might // We'll forward this request to each vendor library. Since a vendor might
// modify the request data in place (e.g., for byte swapping), make a copy // modify the request data in place (e.g., for byte swapping), make a copy
// of the request first. // of the request first.
requestCopy = malloc(requestSize); void *requestCopy = calloc(1, requestSize);
if (requestCopy == NULL) { if (requestCopy == NULL) {
return BadAlloc; return BadAlloc;
} }

View File

@ -64,7 +64,7 @@ __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
widthPadded = GLYPHWIDTHBYTESPADDED(pci); widthPadded = GLYPHWIDTHBYTESPADDED(pci);
/* /*
** Use the local buf if possible, otherwise malloc. ** Use the local buf if possible, otherwise calloc.
*/ */
allocBytes = widthPadded * h; allocBytes = widthPadded * h;
if (allocBytes <= __GL_CHAR_BUF_SIZE) { if (allocBytes <= __GL_CHAR_BUF_SIZE) {
@ -72,7 +72,7 @@ __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
allocbuf = 0; allocbuf = 0;
} }
else { else {
p = (unsigned char *) malloc(allocBytes); p = calloc(1, allocBytes);
if (!p) if (!p)
return BadAlloc; return BadAlloc;
allocbuf = p; allocbuf = p;

View File

@ -75,9 +75,7 @@ ephyrInitialize(KdCardInfo * card, EphyrPriv * priv)
Bool Bool
ephyrCardInit(KdCardInfo * card) ephyrCardInit(KdCardInfo * card)
{ {
EphyrPriv *priv; EphyrPriv *priv = calloc(1, sizeof(EphyrPriv));
priv = (EphyrPriv *) malloc(sizeof(EphyrPriv));
if (!priv) if (!priv)
return FALSE; return FALSE;

View File

@ -144,11 +144,10 @@ ephyr_glamor_build_glsl_prog(GLuint vs, GLuint fs)
glLinkProgram(prog); glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &ok); glGetProgramiv(prog, GL_LINK_STATUS, &ok);
if (!ok) { if (!ok) {
GLchar *info;
GLint size; GLint size;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size); glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size); GLchar *info = calloc(1, size);
glGetProgramInfoLog(prog, size, NULL, info); glGetProgramInfoLog(prog, size, NULL, info);
ErrorF("Failed to link: %s\n", info); ErrorF("Failed to link: %s\n", info);
@ -352,7 +351,7 @@ ephyr_glamor_screen_init(xcb_window_t win, xcb_visualid_t vid)
glamor = calloc(1, sizeof(struct ephyr_glamor)); glamor = calloc(1, sizeof(struct ephyr_glamor));
if (!glamor) { if (!glamor) {
FatalError("malloc"); FatalError("calloc");
return NULL; return NULL;
} }

View File

@ -241,7 +241,6 @@ hostx_get_output_geometry(const char *output,
int *width, int *height) int *width, int *height)
{ {
int i, name_len = 0, output_found = FALSE; int i, name_len = 0, output_found = FALSE;
char *name = NULL;
xcb_generic_error_t *error; xcb_generic_error_t *error;
xcb_randr_query_version_cookie_t version_c; xcb_randr_query_version_cookie_t version_c;
xcb_randr_query_version_reply_t *version_r; xcb_randr_query_version_reply_t *version_r;
@ -300,7 +299,7 @@ hostx_get_output_geometry(const char *output,
/* Get output name */ /* Get output name */
name_len = xcb_randr_get_output_info_name_length(output_info_r); name_len = xcb_randr_get_output_info_name_length(output_info_r);
name = malloc(name_len + 1); char *name = calloc(1, name_len + 1);
strncpy(name, (char*)xcb_randr_get_output_info_name(output_info_r), name_len); strncpy(name, (char*)xcb_randr_get_output_info_name(output_info_r), name_len);
name[name_len] = '\0'; name[name_len] = '\0';
@ -524,7 +523,6 @@ hostx_init(void)
uint32_t pixel; uint32_t pixel;
int index; int index;
char *tmpstr; char *tmpstr;
char *class_hint;
size_t class_len; size_t class_len;
xcb_screen_t *xscreen; xcb_screen_t *xscreen;
xcb_rectangle_t rect = { 0, 0, 1, 1 }; xcb_rectangle_t rect = { 0, 0, 1, 1 };
@ -649,7 +647,7 @@ hostx_init(void)
if (tmpstr && (!ephyrResNameFromCmd)) if (tmpstr && (!ephyrResNameFromCmd))
ephyrResName = tmpstr; ephyrResName = tmpstr;
class_len = strlen(ephyrResName) + 1 + strlen("Xephyr") + 1; class_len = strlen(ephyrResName) + 1 + strlen("Xephyr") + 1;
class_hint = malloc(class_len); char *class_hint = calloc(1, class_len);
if (class_hint) { if (class_hint) {
strcpy(class_hint, ephyrResName); strcpy(class_hint, ephyrResName);
strcpy(class_hint + strlen(ephyrResName) + 1, "Xephyr"); strcpy(class_hint + strlen(ephyrResName) + 1, "Xephyr");

View File

@ -133,7 +133,7 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
KdXvScreenKey = XvGetScreenKey(); KdXvScreenKey = XvGetScreenKey();
PortResource = XvGetRTPort(); PortResource = XvGetRTPort();
ScreenPriv = malloc(sizeof(KdXVScreenRec)); ScreenPriv = calloc(1, sizeof(KdXVScreenRec));
dixSetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey, ScreenPriv); dixSetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv) if (!ScreenPriv)
@ -721,7 +721,7 @@ KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
} }
if (!winPriv) { if (!winPriv) {
winPriv = malloc(sizeof(KdXVWindowRec)); winPriv = calloc(1, sizeof(KdXVWindowRec));
if (!winPriv) if (!winPriv)
return BadAlloc; return BadAlloc;
winPriv->PortRec = portPriv; winPriv->PortRec = portPriv;

View File

@ -694,7 +694,7 @@ vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb)
#endif #endif
case NORMAL_MEMORY_FB: case NORMAL_MEMORY_FB:
pvfb->pXWDHeader = (XWDFileHeader *) malloc(pvfb->sizeInBytes); pvfb->pXWDHeader = (XWDFileHeader *) calloc(1, pvfb->sizeInBytes);
break; break;
} }

View File

@ -324,16 +324,14 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md)
static Bool static Bool
copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver) copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
{ {
confScreenPtr nscreen;
GDevPtr cptr = NULL;
char *identifier; char *identifier;
nscreen = malloc(sizeof(confScreenRec)); confScreenPtr nscreen = calloc(1, sizeof(confScreenRec));
if (!nscreen) if (!nscreen)
return FALSE; return FALSE;
memcpy(nscreen, oscreen, sizeof(confScreenRec)); memcpy(nscreen, oscreen, sizeof(confScreenRec));
cptr = malloc(sizeof(GDevRec)); GDevPtr cptr = calloc(1, sizeof(GDevRec));
if (!cptr) { if (!cptr) {
free(nscreen); free(nscreen);
return FALSE; return FALSE;

View File

@ -339,9 +339,7 @@ configureLayoutSection(void)
ptr->lay_identifier = "X.org Configured"; ptr->lay_identifier = "X.org Configured";
{ {
XF86ConfInputrefPtr iptr; XF86ConfInputrefPtr iptr = calloc(1, sizeof(XF86ConfInputrefRec));
iptr = malloc(sizeof(XF86ConfInputrefRec));
iptr->list.next = NULL; iptr->list.next = NULL;
iptr->iref_option_lst = NULL; iptr->iref_option_lst = NULL;
iptr->iref_inputdev_str = XNFstrdup("Mouse0"); iptr->iref_inputdev_str = XNFstrdup("Mouse0");
@ -353,9 +351,7 @@ configureLayoutSection(void)
} }
{ {
XF86ConfInputrefPtr iptr; XF86ConfInputrefPtr iptr = calloc(1, sizeof(XF86ConfInputrefRec));
iptr = malloc(sizeof(XF86ConfInputrefRec));
iptr->list.next = NULL; iptr->list.next = NULL;
iptr->iref_option_lst = NULL; iptr->iref_option_lst = NULL;
iptr->iref_inputdev_str = XNFstrdup("Keyboard0"); iptr->iref_inputdev_str = XNFstrdup("Keyboard0");
@ -367,10 +363,9 @@ configureLayoutSection(void)
} }
for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
XF86ConfAdjacencyPtr aptr;
char *tmp; char *tmp;
aptr = malloc(sizeof(XF86ConfAdjacencyRec)); XF86ConfAdjacencyPtr aptr = calloc(1, sizeof(XF86ConfAdjacencyRec));
aptr->list.next = NULL; aptr->list.next = NULL;
aptr->adj_x = 0; aptr->adj_x = 0;
aptr->adj_y = 0; aptr->adj_y = 0;

View File

@ -482,7 +482,7 @@ AddEdge(xf86EdgePtr edge,
} }
if (!pEdge) { if (!pEdge) {
if (!(pNew = malloc(sizeof(xf86EdgeRec)))) if (!(pNew = calloc(1, sizeof(xf86EdgeRec))))
break; break;
pNew->screen = screen; pNew->screen = screen;
@ -500,7 +500,7 @@ AddEdge(xf86EdgePtr edge,
break; break;
} }
else if (min < pEdge->start) { else if (min < pEdge->start) {
if (!(pNew = malloc(sizeof(xf86EdgeRec)))) if (!(pNew = calloc(1, sizeof(xf86EdgeRec))))
break; break;
pNew->screen = screen; pNew->screen = screen;

View File

@ -146,7 +146,7 @@ DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num)
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv) { if (!pScreenPriv) {
if (!(pScreenPriv = (DGAScreenPtr) malloc(sizeof(DGAScreenRec)))) if (!(pScreenPriv = calloc(1, sizeof(DGAScreenRec))))
return FALSE; return FALSE;
dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CloseScreen = pScreen->CloseScreen;
@ -400,7 +400,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet)
else else
return BadValue; return BadValue;
if (!(device = (DGADevicePtr) malloc(sizeof(DGADeviceRec)))) if (!(device = calloc(1, sizeof(DGADeviceRec))))
return BadAlloc; return BadAlloc;
if (!pScreenPriv->current) { if (!pScreenPriv->current) {
@ -664,7 +664,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
pMode = &(pScreenPriv->modes[mode - 1]); pMode = &(pScreenPriv->modes[mode - 1]);
if (!(pVisual = malloc(sizeof(VisualRec)))) if (!(pVisual = calloc(1, sizeof(VisualRec))))
return BadAlloc; return BadAlloc;
pVisual->vid = FakeClientID(0); pVisual->vid = FakeClientID(0);
@ -698,7 +698,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
pVisual->offsetBlue = BitsClear(pVisual->blueMask); pVisual->offsetBlue = BitsClear(pVisual->blueMask);
} }
if (!(fvlp = malloc(sizeof(FakedVisualList)))) { if (!(fvlp = calloc(1, sizeof(FakedVisualList)))) {
free(pVisual); free(pVisual);
return BadAlloc; return BadAlloc;
} }
@ -1682,7 +1682,7 @@ ProcXDGASetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
if ((pPriv = DGA_GETPRIV(client)) == NULL) { if ((pPriv = DGA_GETPRIV(client)) == NULL) {
pPriv = malloc(sizeof(DGAPrivRec)); pPriv = calloc(1, sizeof(DGAPrivRec));
/* XXX Need to look into freeing this */ /* XXX Need to look into freeing this */
if (!pPriv) if (!pPriv)
return BadAlloc; return BadAlloc;

View File

@ -898,13 +898,13 @@ xf86NameCmp(const char *s1, const char *s2)
char * char *
xf86NormalizeName(const char *s) xf86NormalizeName(const char *s)
{ {
char *ret, *q; char *q;
const char *p; const char *p;
if (s == NULL) if (s == NULL)
return NULL; return NULL;
ret = malloc(strlen(s) + 1); char *ret = calloc(1, strlen(s) + 1);
for (p = s, q = ret; *p != 0; p++) { for (p = s, q = ret; *p != 0; p++) {
switch (*p) { switch (*p) {
case '_': case '_':

View File

@ -406,7 +406,6 @@ Bool
xf86RandRInit(ScreenPtr pScreen) xf86RandRInit(ScreenPtr pScreen)
{ {
rrScrPrivPtr rp; rrScrPrivPtr rp;
XF86RandRInfoPtr randrp;
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen); ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
#ifdef XINERAMA #ifdef XINERAMA
@ -420,7 +419,7 @@ xf86RandRInit(ScreenPtr pScreen)
if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
randrp = malloc(sizeof(XF86RandRInfoRec)); XF86RandRInfoPtr randrp = calloc(1, sizeof(XF86RandRInfoRec));
if (!randrp) if (!randrp)
return FALSE; return FALSE;

View File

@ -184,7 +184,7 @@ xf86VGAarbiterWrapFunctions(void)
if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec)))) if (!(pScreenPriv = calloc(1, sizeof(VGAarbiterScreenRec))))
return FALSE; return FALSE;
dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);

View File

@ -168,7 +168,7 @@ xf86HandleColormaps(ScreenPtr pScreen,
return FALSE; return FALSE;
} }
if (!(pScreenPriv = malloc(sizeof(CMapScreenRec)))) { if (!(pScreenPriv = calloc(1, sizeof(CMapScreenRec)))) {
free(gamma); free(gamma);
free(indices); free(indices);
return FALSE; return FALSE;
@ -264,7 +264,6 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
(CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates, (CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates,
CMapScreenKey); CMapScreenKey);
CMapColormapPtr pColPriv; CMapColormapPtr pColPriv;
CMapLinkPtr pLink;
int numColors; int numColors;
LOCO *colors; LOCO *colors;
@ -276,7 +275,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
if (!(colors = xallocarray(numColors, sizeof(LOCO)))) if (!(colors = xallocarray(numColors, sizeof(LOCO))))
return FALSE; return FALSE;
if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) { if (!(pColPriv = calloc(1, sizeof(CMapColormapRec)))) {
free(colors); free(colors);
return FALSE; return FALSE;
} }
@ -289,7 +288,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
pColPriv->overscan = -1; pColPriv->overscan = -1;
/* add map to list */ /* add map to list */
pLink = malloc(sizeof(CMapLink)); CMapLinkPtr pLink = calloc(1, sizeof(CMapLink));
if (pLink) { if (pLink) {
pLink->cmap = pmap; pLink->cmap = pmap;
pLink->next = pScreenPriv->maps; pLink->next = pScreenPriv->maps;

View File

@ -371,7 +371,7 @@ AllocateArea(FBManagerPtr offman,
if (((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) if (((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
continue; continue;
link = malloc(sizeof(FBLink)); link = calloc(1, sizeof(FBLink));
if (!link) if (!link)
return NULL; return NULL;
@ -829,7 +829,6 @@ AllocateLinear(FBManagerPtr offman, int size, int granularity, void *privData)
{ {
ScreenPtr pScreen = offman->pScreen; ScreenPtr pScreen = offman->pScreen;
FBLinearLinkPtr linear = NULL; FBLinearLinkPtr linear = NULL;
FBLinearLinkPtr newlink = NULL;
int offset, end; int offset, end;
if (size <= 0) if (size <= 0)
@ -857,7 +856,7 @@ AllocateLinear(FBManagerPtr offman, int size, int granularity, void *privData)
/* break left */ /* break left */
if (offset > linear->linear.offset) { if (offset > linear->linear.offset) {
newlink = malloc(sizeof(FBLinearLink)); FBLinearLinkPtr newlink = calloc(1, sizeof(FBLinearLink));
if (!newlink) if (!newlink)
return NULL; return NULL;
newlink->area = NULL; newlink->area = NULL;
@ -873,7 +872,7 @@ AllocateLinear(FBManagerPtr offman, int size, int granularity, void *privData)
/* break right */ /* break right */
if (size < linear->linear.size) { if (size < linear->linear.size) {
newlink = malloc(sizeof(FBLinearLink)); FBLinearLinkPtr newlink = calloc(1, sizeof(FBLinearLink));
if (!newlink) if (!newlink)
return NULL; return NULL;
newlink->area = NULL; newlink->area = NULL;
@ -923,7 +922,7 @@ localAllocateOffscreenLinear(ScreenPtr pScreen,
DebugF("NOPE, ALLOCATING AREA\n"); DebugF("NOPE, ALLOCATING AREA\n");
if (!(link = malloc(sizeof(FBLinearLink)))) if (!(link = calloc(1, sizeof(FBLinearLink))))
return NULL; return NULL;
/* No linear available, so try and pinch some from the XY areas */ /* No linear available, so try and pinch some from the XY areas */
@ -1309,7 +1308,6 @@ xf86InitFBManagerArea(ScreenPtr pScreen, int PixelArea, int Verbosity)
Bool Bool
xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr FullRegion) xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr FullRegion)
{ {
FBManagerPtr offman;
if (RegionNil(FullRegion)) if (RegionNil(FullRegion))
return FALSE; return FALSE;
@ -1320,7 +1318,7 @@ xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr FullRegion)
if (!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) if (!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE; return FALSE;
offman = malloc(sizeof(FBManager)); FBManagerPtr offman = calloc(1, sizeof(FBManager));
if (!offman) if (!offman)
return FALSE; return FALSE;
@ -1362,7 +1360,7 @@ xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size)
offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates, offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey); xf86FBScreenKey);
offman->LinearAreas = malloc(sizeof(FBLinearLink)); offman->LinearAreas = calloc(1, sizeof(FBLinearLink));
if (!offman->LinearAreas) if (!offman->LinearAreas)
return FALSE; return FALSE;

View File

@ -1358,7 +1358,7 @@ xf86MatchDriverFromFiles(uint16_t match_vendor, uint16_t match_chip,
} }
if (vendor == match_vendor && chip == match_chip) { if (vendor == match_vendor && chip == match_chip) {
tmpMatch = tmpMatch =
(char *) malloc(sizeof(char) * (char *) calloc(1, sizeof(char) *
strlen(direntry->d_name) - 3); strlen(direntry->d_name) - 3);
if (!tmpMatch) { if (!tmpMatch) {
LogMessageVerb(X_ERROR, 1, LogMessageVerb(X_ERROR, 1,

View File

@ -86,7 +86,7 @@ xf86SbusProbe(void)
char fbDevName[32]; char fbDevName[32];
sbusDevicePtr psdp, *psdpp; sbusDevicePtr psdp, *psdpp;
xf86SbusInfo = malloc(sizeof(psdp)); xf86SbusInfo = calloc(1, sizeof(psdp));
*xf86SbusInfo = NULL; *xf86SbusInfo = NULL;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
snprintf(fbDevName, sizeof(fbDevName), "/dev/fb%d", i); snprintf(fbDevName, sizeof(fbDevName), "/dev/fb%d", i);

View File

@ -245,7 +245,7 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
PortResource = XvGetRTPort(); PortResource = XvGetRTPort();
ScreenPriv = malloc(sizeof(XF86XVScreenRec)); ScreenPriv = calloc(1, sizeof(XF86XVScreenRec));
dixSetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey, ScreenPriv); dixSetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv) if (!ScreenPriv)

View File

@ -163,7 +163,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
return FALSE; return FALSE;
} }
if (!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) { if (!(pScreenPriv = calloc(1, sizeof(xf86XvMCScreenRec)))) {
free(pAdapt); free(pAdapt);
return FALSE; return FALSE;
} }

View File

@ -64,12 +64,10 @@
XISBuffer * XISBuffer *
XisbNew(int fd, ssize_t size) XisbNew(int fd, ssize_t size)
{ {
XISBuffer *b; XISBuffer *b = calloc(1, sizeof(XISBuffer));
b = malloc(sizeof(XISBuffer));
if (!b) if (!b)
return NULL; return NULL;
b->buf = malloc((sizeof(unsigned char) * size)); b->buf = calloc(sizeof(unsigned char), size);
if (!b->buf) { if (!b->buf) {
free(b); free(b);
return NULL; return NULL;

View File

@ -90,7 +90,7 @@ find_header(unsigned char *block)
static unsigned char * static unsigned char *
resort(unsigned char *s_block) resort(unsigned char *s_block)
{ {
unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end; unsigned char *d_ptr, *d_end, *s_ptr, *s_end;
unsigned char tmp; unsigned char tmp;
s_ptr = find_header(s_block); s_ptr = find_header(s_block);
@ -98,7 +98,7 @@ resort(unsigned char *s_block)
return NULL; return NULL;
s_end = s_block + EDID1_LEN; s_end = s_block + EDID1_LEN;
d_new = malloc(EDID1_LEN); unsigned char *d_new = calloc(1, EDID1_LEN);
if (!d_new) if (!d_new)
return NULL; return NULL;
d_end = d_new + EDID1_LEN; d_end = d_new + EDID1_LEN;
@ -186,7 +186,7 @@ FetchEDID_DDC1(register ScrnInfoPtr pScrn,
int count = NUM; int count = NUM;
unsigned int *ptr, *xp; unsigned int *ptr, *xp;
ptr = xp = malloc(sizeof(int) * NUM); ptr = xp = calloc(NUM, sizeof(int));
if (!ptr) if (!ptr)
return NULL; return NULL;
@ -413,9 +413,7 @@ xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool complete)
/* Default DDC and DDC2 to enabled. */ /* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE; Bool noddc = FALSE, noddc2 = FALSE;
OptionInfoPtr options; OptionInfoPtr options = calloc(1, sizeof(DDCOptions));
options = malloc(sizeof(DDCOptions));
if (!options) if (!options)
return NULL; return NULL;
memcpy(options, DDCOptions, sizeof(DDCOptions)); memcpy(options, DDCOptions, sizeof(DDCOptions));

View File

@ -1285,7 +1285,7 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
} }
else { else {
/* allocate a DRI Window Private record */ /* allocate a DRI Window Private record */
if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) { if (!(pDRIDrawablePriv = calloc(1, sizeof(DRIDrawablePrivRec)))) {
return FALSE; return FALSE;
} }

View File

@ -235,12 +235,11 @@ static DRI2DrawablePtr
DRI2AllocateDrawable(DrawablePtr pDraw) DRI2AllocateDrawable(DrawablePtr pDraw)
{ {
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
CARD64 ust; CARD64 ust;
WindowPtr pWin; WindowPtr pWin;
PixmapPtr pPixmap; PixmapPtr pPixmap;
pPriv = malloc(sizeof *pPriv); DRI2DrawablePtr pPriv = calloc(1, sizeof *pPriv);
if (pPriv == NULL) if (pPriv == NULL)
return NULL; return NULL;
@ -327,9 +326,7 @@ static int
DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id, DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
DRI2InvalidateProcPtr invalidate, void *priv) DRI2InvalidateProcPtr invalidate, void *priv)
{ {
DRI2DrawableRefPtr ref; DRI2DrawableRefPtr ref = calloc(1, sizeof *ref);
ref = malloc(sizeof *ref);
if (ref == NULL) if (ref == NULL)
return BadAlloc; return BadAlloc;

View File

@ -88,7 +88,6 @@ struct ms_dri2_resource {
static struct ms_dri2_resource * static struct ms_dri2_resource *
ms_get_resource(XID id, RESTYPE type) ms_get_resource(XID id, RESTYPE type)
{ {
struct ms_dri2_resource *resource;
void *ptr; void *ptr;
ptr = NULL; ptr = NULL;
@ -96,7 +95,7 @@ ms_get_resource(XID id, RESTYPE type)
if (ptr) if (ptr)
return ptr; return ptr;
resource = malloc(sizeof(*resource)); struct ms_dri2_resource *resource = calloc(1, sizeof(*resource));
if (resource == NULL) if (resource == NULL)
return NULL; return NULL;

View File

@ -1327,7 +1327,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
/* Process the options */ /* Process the options */
xf86CollectOptions(pScrn, NULL); xf86CollectOptions(pScrn, NULL);
if (!(ms->drmmode.Options = malloc(sizeof(Options)))) if (!(ms->drmmode.Options = calloc(1, sizeof(Options))))
return FALSE; return FALSE;
memcpy(ms->drmmode.Options, Options, sizeof(Options)); memcpy(ms->drmmode.Options, Options, sizeof(Options));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->drmmode.Options); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->drmmode.Options);

View File

@ -410,7 +410,7 @@ drmmode_prop_info_copy(drmmode_prop_info_ptr dst,
continue; continue;
dst[i].enum_values = dst[i].enum_values =
malloc(src[i].num_enum_values * calloc(src[i].num_enum_values,
sizeof(*dst[i].enum_values)); sizeof(*dst[i].enum_values));
if (!dst[i].enum_values) if (!dst[i].enum_values)
goto err; goto err;
@ -4121,7 +4121,7 @@ drmmode_crtc_upgrade_lut(xf86CrtcPtr crtc, int num)
if (size != crtc->gamma_size) { if (size != crtc->gamma_size) {
ScrnInfoPtr pScrn = crtc->scrn; ScrnInfoPtr pScrn = crtc->scrn;
uint16_t *gamma = malloc(3 * size * sizeof(uint16_t)); uint16_t *gamma = calloc(3 * size, sizeof(uint16_t));
if (gamma) { if (gamma) {
free(crtc->gamma_red); free(crtc->gamma_red);

View File

@ -207,7 +207,7 @@ xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex)
configOptions = pEnt->device->options; configOptions = pEnt->device->options;
if (configOptions) { if (configOptions) {
if (!(options = (OptionInfoPtr) malloc(sizeof(INT10Options)))) if (!(options = (OptionInfoPtr) calloc(1, sizeof(INT10Options))))
return NULL; return NULL;
(void) memcpy(options, INT10Options, sizeof(INT10Options)); (void) memcpy(options, INT10Options, sizeof(INT10Options));

View File

@ -505,8 +505,6 @@ VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
VbeModeInfoBlock * VbeModeInfoBlock *
VBEGetModeInfo(vbeInfoPtr pVbe, int mode) VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
{ {
VbeModeInfoBlock *block = NULL;
memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock)); memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
/* /*
@ -530,7 +528,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
if (R16(pVbe->pInt10->ax) != 0x4f) if (R16(pVbe->pInt10->ax) != 0x4f)
return NULL; return NULL;
block = malloc(sizeof(VbeModeInfoBlock)); VbeModeInfoBlock *block = calloc(1, sizeof(VbeModeInfoBlock));
if (block) if (block)
memcpy(block, pVbe->memory, sizeof(*block)); memcpy(block, pVbe->memory, sizeof(*block));
@ -834,7 +832,6 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
VBEpmi * VBEpmi *
VBEGetVBEpmi(vbeInfoPtr pVbe) VBEGetVBEpmi(vbeInfoPtr pVbe)
{ {
VBEpmi *pmi;
/* /*
Input: Input:
@ -859,7 +856,7 @@ VBEGetVBEpmi(vbeInfoPtr pVbe)
if (R16(pVbe->pInt10->ax) != 0x4f) if (R16(pVbe->pInt10->ax) != 0x4f)
return NULL; return NULL;
pmi = malloc(sizeof(VBEpmi)); VBEpmi *pmi = calloc(1, sizeof(VBEpmi));
pmi->seg_tbl = R16(pVbe->pInt10->es); pmi->seg_tbl = R16(pVbe->pInt10->es);
pmi->tbl_off = R16(pVbe->pInt10->di); pmi->tbl_off = R16(pVbe->pInt10->di);
pmi->tbl_len = R16(pVbe->pInt10->cx); pmi->tbl_len = R16(pVbe->pInt10->cx);
@ -936,7 +933,7 @@ VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
vbe_sr->stateMode = -1; /* invalidate */ vbe_sr->stateMode = -1; /* invalidate */
/* don't rely on the memory not being touched */ /* don't rely on the memory not being touched */
if (vbe_sr->pstate == NULL) if (vbe_sr->pstate == NULL)
vbe_sr->pstate = malloc(vbe_sr->stateSize); vbe_sr->pstate = calloc(1, vbe_sr->stateSize);
memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize); memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
} }
ErrorF("VBESaveRestore done with success\n"); ErrorF("VBESaveRestore done with success\n");

View File

@ -142,7 +142,7 @@ InitPathList(const char *path)
free(fullpath); free(fullpath);
return NULL; return NULL;
} }
list[n] = malloc(len + 1); list[n] = calloc(1, len + 1);
if (!list[n]) { if (!list[n]) {
FreeStringList(list); FreeStringList(list);
free(fullpath); free(fullpath);
@ -398,7 +398,7 @@ LoaderListDir(const char *subdir, const char **patternlist)
closedir(d); closedir(d);
goto bail; goto bail;
} }
listing[n] = malloc(len + 1); listing[n] = calloc(1, len + 1);
if (!listing[n]) { if (!listing[n]) {
FreeStringList(listing); FreeStringList(listing);
closedir(d); closedir(d);
@ -723,7 +723,7 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq,
pathlist = defaultPathList; pathlist = defaultPathList;
if (!pathlist) { if (!pathlist) {
/* This could be a malloc failure too */ /* This could be a calloc failure too */
if (errmaj) if (errmaj)
*errmaj = LDR_BADUSAGE; *errmaj = LDR_BADUSAGE;
goto LoadModule_fail; goto LoadModule_fail;
@ -962,7 +962,6 @@ LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin)
static char * static char *
LoaderGetCanonicalName(const char *modname, PatternPtr patterns) LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
{ {
char *str;
const char *s; const char *s;
int len; int len;
PatternPtr p; PatternPtr p;
@ -979,7 +978,7 @@ LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
for (p = patterns; p->pattern; p++) for (p = patterns; p->pattern; p++)
if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) { if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
len = match[1].rm_eo - match[1].rm_so; len = match[1].rm_eo - match[1].rm_so;
str = malloc(len + 1); char *str = calloc(1, len + 1);
if (!str) if (!str)
return NULL; return NULL;
strncpy(str, s + match[1].rm_so, len); strncpy(str, s + match[1].rm_so, len);

View File

@ -649,7 +649,7 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
if (!cursor_info) if (!cursor_info)
return FALSE; return FALSE;
xf86_config->cursor_image = malloc(max_width * max_height * 4); xf86_config->cursor_image = calloc(max_width * max_height, 4);
if (!xf86_config->cursor_image) { if (!xf86_config->cursor_image) {
xf86DestroyCursorInfoRec(cursor_info); xf86DestroyCursorInfoRec(cursor_info);

View File

@ -847,7 +847,6 @@ Bool
xf86RandR12Init(ScreenPtr pScreen) xf86RandR12Init(ScreenPtr pScreen)
{ {
rrScrPrivPtr rp; rrScrPrivPtr rp;
XF86RandRInfoPtr randrp;
#ifdef XINERAMA #ifdef XINERAMA
/* XXX disable RandR when using Xinerama */ /* XXX disable RandR when using Xinerama */
@ -865,7 +864,7 @@ xf86RandR12Init(ScreenPtr pScreen)
if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
randrp = malloc(sizeof(XF86RandRInfoRec)); XF86RandRInfoPtr randrp = calloc(1, sizeof(XF86RandRInfoRec));
if (!randrp) if (!randrp)
return FALSE; return FALSE;

View File

@ -457,7 +457,7 @@ xf86CrtcRotate(xf86CrtcPtr crtc)
#ifdef RANDR_12_INTERFACE #ifdef RANDR_12_INTERFACE
if (transform) { if (transform) {
if (transform->nparams) { if (transform->nparams) {
new_params = malloc(transform->nparams * sizeof(xFixed)); new_params = calloc(transform->nparams, sizeof(xFixed));
if (new_params) { if (new_params) {
memcpy(new_params, transform->params, memcpy(new_params, transform->params,
transform->nparams * sizeof(xFixed)); transform->nparams * sizeof(xFixed));

View File

@ -213,7 +213,7 @@ sparcPromInit(void)
promFd = open("/dev/openprom", O_RDONLY, 0); promFd = open("/dev/openprom", O_RDONLY, 0);
if (promFd == -1) if (promFd == -1)
return -1; return -1;
promOpio = (struct openpromio *) malloc(4096); promOpio = (struct openpromio *) calloc(1, 4096);
if (!promOpio) { if (!promOpio) {
sparcPromClose(); sparcPromClose();
return -1; return -1;
@ -535,11 +535,9 @@ promWalkNode2Pathname(char *path, int parent, int node, int searchNode,
char * char *
sparcPromNode2Pathname(sbusPromNodePtr pnode) sparcPromNode2Pathname(sbusPromNodePtr pnode)
{ {
char *ret;
if (!pnode->node) if (!pnode->node)
return NULL; return NULL;
ret = malloc(4096); char *ret = calloc(1, 4096);
if (!ret) if (!ret)
return NULL; return NULL;
if (promWalkNode2Pathname if (promWalkNode2Pathname
@ -609,10 +607,10 @@ int
sparcPromPathname2Node(const char *pathName) sparcPromPathname2Node(const char *pathName)
{ {
int i; int i;
char *name, *regstr, *p; char *regstr, *p;
i = strlen(pathName); i = strlen(pathName);
name = malloc(i + 2); char *name = calloc(1, i + 2);
if (!name) if (!name)
return 0; return 0;
strcpy(name, pathName); strcpy(name, pathName);

View File

@ -121,7 +121,7 @@ xf86parseFilesSection(void)
l = FALSE; l = FALSE;
str = xf86_lex_val.str; str = xf86_lex_val.str;
if (ptr->file_modulepath == NULL) { if (ptr->file_modulepath == NULL) {
ptr->file_modulepath = malloc(1); ptr->file_modulepath = calloc(1, 1);
ptr->file_modulepath[0] = '\0'; ptr->file_modulepath[0] = '\0';
k = strlen(str) + 1; k = strlen(str) + 1;
} }

View File

@ -155,9 +155,7 @@ enum MatchType {
static void static void
add_group_entry(struct xorg_list *head, char **values, enum MatchType type) add_group_entry(struct xorg_list *head, char **values, enum MatchType type)
{ {
xf86MatchGroup *group; xf86MatchGroup *group = calloc(1, sizeof(xf86MatchGroup));
group = malloc(sizeof(*group));
if (group) { if (group) {
group->is_negated = (type == MATCH_NEGATED); group->is_negated = (type == MATCH_NEGATED);
group->values = values; group->values = values;

View File

@ -78,9 +78,7 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr)
static void static void
add_group_entry(struct xorg_list *head, char **values) add_group_entry(struct xorg_list *head, char **values)
{ {
xf86MatchGroup *group; xf86MatchGroup *group = calloc(1, sizeof(xf86MatchGroup));
group = malloc(sizeof(*group));
if (group) { if (group) {
group->values = values; group->values = values;
xorg_list_add(&group->entry, head); xorg_list_add(&group->entry, head);

View File

@ -118,20 +118,20 @@ xf86getNextLine(void)
/* /*
* reallocate the string if it was grown last time (i.e., is no * reallocate the string if it was grown last time (i.e., is no
* longer CONFIG_BUF_LEN); we malloc the new strings first, so * longer CONFIG_BUF_LEN); we calloc the new strings first, so
* that if either of the mallocs fail, we can fall back on the * that if either of the callocs fail, we can fall back on the
* existing buffer allocations * existing buffer allocations
*/ */
if (configBufLen != CONFIG_BUF_LEN) { if (configBufLen != CONFIG_BUF_LEN) {
tmpConfigBuf = malloc(CONFIG_BUF_LEN); tmpConfigBuf = calloc(1, CONFIG_BUF_LEN);
tmpConfigRBuf = malloc(CONFIG_BUF_LEN); tmpConfigRBuf = calloc(1, CONFIG_BUF_LEN);
if (!tmpConfigBuf || !tmpConfigRBuf) { if (!tmpConfigBuf || !tmpConfigRBuf) {
/* /*
* at least one of the mallocs failed; keep the old buffers * at least one of the callocs failed; keep the old buffers
* and free any partial allocations * and free any partial allocations
*/ */
@ -142,7 +142,7 @@ xf86getNextLine(void)
else { else {
/* /*
* malloc succeeded; free the old buffers and use the new * calloc succeeded; free the old buffers and use the new
* buffers * buffers
*/ */
@ -393,7 +393,7 @@ xf86getToken(const xf86ConfigSymTabRec * tab)
} }
while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0')); while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
configRBuf[i] = '\0'; configRBuf[i] = '\0';
xf86_lex_val.str = malloc(strlen(configRBuf) + 1); xf86_lex_val.str = calloc(1, strlen(configRBuf) + 1);
strcpy(xf86_lex_val.str, configRBuf); /* private copy ! */ strcpy(xf86_lex_val.str, configRBuf); /* private copy ! */
return STRING; return STRING;
} }
@ -569,7 +569,6 @@ static char *
DoSubstitution(const char *template, const char *cmdline, const char *projroot, DoSubstitution(const char *template, const char *cmdline, const char *projroot,
int *cmdlineUsed, int *envUsed, const char *XConfigFile) int *cmdlineUsed, int *envUsed, const char *XConfigFile)
{ {
char *result;
int i, l; int i, l;
static const char *env = NULL; static const char *env = NULL;
static char *hostname = NULL; static char *hostname = NULL;
@ -582,7 +581,7 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
if (envUsed) if (envUsed)
*envUsed = 0; *envUsed = 0;
result = malloc(PATH_MAX + 1); char *result = calloc(1, PATH_MAX + 1);
l = 0; l = 0;
for (i = 0; template[i]; i++) { for (i = 0; template[i]; i++) {
if (template[i] != '%') { if (template[i] != '%') {
@ -623,7 +622,7 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
break; break;
case 'H': case 'H':
if (!hostname) { if (!hostname) {
if ((hostname = malloc(MAXHOSTNAMELEN + 1))) { if ((hostname = calloc(1, MAXHOSTNAMELEN + 1))) {
if (gethostname(hostname, MAXHOSTNAMELEN) == 0) { if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
hostname[MAXHOSTNAMELEN] = '\0'; hostname[MAXHOSTNAMELEN] = '\0';
} }
@ -769,7 +768,6 @@ AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
Bool warnOnce = FALSE; Bool warnOnce = FALSE;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
char *path;
FILE *file; FILE *file;
if (numFiles >= CONFIG_MAX_FILES) { if (numFiles >= CONFIG_MAX_FILES) {
@ -780,7 +778,7 @@ AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
continue; continue;
} }
path = malloc(PATH_MAX + 1); char *path = calloc(1, PATH_MAX + 1);
snprintf(path, PATH_MAX + 1, "%s/%s", dirpath, list[i]->d_name); snprintf(path, PATH_MAX + 1, "%s/%s", dirpath, list[i]->d_name);
file = fopen(path, "r"); file = fopen(path, "r");
if (!file) { if (!file) {
@ -857,8 +855,8 @@ xf86initConfigFiles(void)
configLineNo = 0; configLineNo = 0;
pushToken = LOCK_TOKEN; pushToken = LOCK_TOKEN;
configBuf = malloc(CONFIG_BUF_LEN); configBuf = calloc(1, CONFIG_BUF_LEN);
configRBuf = malloc(CONFIG_BUF_LEN); configRBuf = calloc(1, CONFIG_BUF_LEN);
configBuf[0] = '\0'; /* sanity ... */ configBuf[0] = '\0'; /* sanity ... */
} }

View File

@ -61,7 +61,7 @@ ShadowFBInit2(ScreenPtr pScreen,
if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
if (!(pPriv = (ShadowScreenPtr) malloc(sizeof(ShadowScreenRec)))) if (!(pPriv = (ShadowScreenPtr) calloc(1, sizeof(ShadowScreenRec))))
return FALSE; return FALSE;
dixSetPrivate(&pScreen->devPrivates, &ShadowScreenKeyRec, pPriv); dixSetPrivate(&pScreen->devPrivates, &ShadowScreenKeyRec, pPriv);

View File

@ -294,7 +294,7 @@ vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
float h_front_porch; float h_front_porch;
float v_odd_front_porch_lines; float v_odd_front_porch_lines;
mode *m = (mode *) malloc(sizeof(mode)); mode *m = (mode *) calloc(1, sizeof(mode));
/* 1. In order to give correct results, the number of horizontal /* 1. In order to give correct results, the number of horizontal
* pixels requested is first processed to ensure that it is divisible * pixels requested is first processed to ensure that it is divisible

View File

@ -952,21 +952,21 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
#if SAVE_FONT1 #if SAVE_FONT1
if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) { if (hwp->FontInfo1 || (hwp->FontInfo1 = calloc(1, FONT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */ hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */ hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT); slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
} }
#endif /* SAVE_FONT1 */ #endif /* SAVE_FONT1 */
#if SAVE_FONT2 #if SAVE_FONT2
if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) { if (hwp->FontInfo2 || (hwp->FontInfo2 = calloc(1, FONT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */ hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */ hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT); slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
} }
#endif /* SAVE_FONT2 */ #endif /* SAVE_FONT2 */
#if SAVE_TEXT #if SAVE_TEXT
if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) { if (hwp->TextInfo || (hwp->TextInfo = calloc(2, TEXT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */ hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */ hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT); slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);

View File

@ -37,7 +37,6 @@ int xnestFontPrivateIndex;
Bool Bool
xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
{ {
void *priv;
Atom name_atom, value_atom; Atom name_atom, value_atom;
int nprops; int nprops;
FontPropPtr props; FontPropPtr props;
@ -66,7 +65,7 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
if (!name) if (!name)
return FALSE; return FALSE;
priv = (void *) malloc(sizeof(xnestPrivFont)); void *priv = calloc(1, sizeof(xnestPrivFont));
xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv); xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv);
xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name); xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);

View File

@ -167,10 +167,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec)); visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec));
numVisuals = 0; numVisuals = 0;
depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec)); depths = calloc(MAXDEPTH, sizeof(DepthRec));
depths[0].depth = 1; depths[0].depth = 1;
depths[0].numVids = 0; depths[0].numVids = 0;
depths[0].vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); depths[0].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID));
numDepths = 1; numDepths = 1;
for (i = 0; i < xnestNumVisuals; i++) { for (i = 0; i < xnestNumVisuals; i++) {
@ -217,8 +217,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
depthIndex = numDepths; depthIndex = numDepths;
depths[depthIndex].depth = xnestVisuals[i].depth; depths[depthIndex].depth = xnestVisuals[i].depth;
depths[depthIndex].numVids = 0; depths[depthIndex].numVids = 0;
depths[depthIndex].vids = depths[depthIndex].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID));
(VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
numDepths++; numDepths++;
} }
if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) { if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) {

View File

@ -455,7 +455,7 @@ xwl_screen_add_drm_lease_device(struct xwl_screen *xwl_screen, uint32_t id)
{ {
struct wp_drm_lease_device_v1 *lease_device = wl_registry_bind( struct wp_drm_lease_device_v1 *lease_device = wl_registry_bind(
xwl_screen->registry, id, &wp_drm_lease_device_v1_interface, 1); xwl_screen->registry, id, &wp_drm_lease_device_v1_interface, 1);
struct xwl_drm_lease_device *device_data = malloc(sizeof(struct xwl_drm_lease_device)); struct xwl_drm_lease_device *device_data = calloc(1, sizeof(struct xwl_drm_lease_device));
device_data->drm_lease_device = lease_device; device_data->drm_lease_device = lease_device;
device_data->xwl_screen = xwl_screen; device_data->xwl_screen = xwl_screen;

View File

@ -166,7 +166,6 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
Bool implicit_modifier) Bool implicit_modifier)
{ {
PixmapPtr pixmap; PixmapPtr pixmap;
struct xwl_pixmap *xwl_pixmap;
struct xwl_screen *xwl_screen = xwl_screen_get(screen); struct xwl_screen *xwl_screen = xwl_screen_get(screen);
#ifdef GBM_BO_FD_FOR_PLANE #ifdef GBM_BO_FD_FOR_PLANE
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
@ -218,7 +217,7 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
for (plane = 0; plane < num_planes; plane++) fds[plane] = -1; for (plane = 0; plane < num_planes; plane++) fds[plane] = -1;
#endif #endif
xwl_pixmap = calloc(1, sizeof(*xwl_pixmap)); struct xwl_pixmap *xwl_pixmap = calloc(1, sizeof(struct xwl_pixmap));
if (xwl_pixmap == NULL) if (xwl_pixmap == NULL)
return NULL; return NULL;
@ -717,7 +716,6 @@ xwl_dri3_open_client(ClientPtr client,
{ {
struct xwl_screen *xwl_screen = xwl_screen_get(screen); struct xwl_screen *xwl_screen = xwl_screen_get(screen);
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
struct xwl_auth_state *state;
drm_magic_t magic; drm_magic_t magic;
int fd; int fd;
@ -729,7 +727,7 @@ xwl_dri3_open_client(ClientPtr client,
return Success; return Success;
} }
state = malloc(sizeof *state); struct xwl_auth_state *state = calloc(1, sizeof(struct xwl_auth_state));
if (state == NULL) { if (state == NULL) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;

Some files were not shown because too many files have changed in this diff Show More