devPrivates rework: minor fix; use calloc and avoid initialization.
This commit is contained in:
parent
ed75b05651
commit
1d550bb2c5
|
@ -128,12 +128,11 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
|
|||
#endif
|
||||
/* must pre-allocate one private for the new devPrivates support */
|
||||
dev->nPrivates = 1;
|
||||
dev->devPrivates = (DevUnion *)xalloc(sizeof(DevUnion));
|
||||
dev->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
|
||||
if (!dev->devPrivates) {
|
||||
xfree(dev);
|
||||
return NULL;
|
||||
}
|
||||
dev->devPrivates[0].ptr = NULL;
|
||||
|
||||
dev->unwrapProc = NULL;
|
||||
dev->coreEvents = TRUE;
|
||||
|
|
13
dix/main.c
13
dix/main.c
|
@ -720,20 +720,17 @@ AddScreen(
|
|||
|
||||
/* must pre-allocate one private for the new devPrivates support */
|
||||
pScreen->WindowPrivateLen = 1;
|
||||
pScreen->WindowPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
||||
pScreen->WindowPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||
pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
|
||||
pScreen->GCPrivateLen = 1;
|
||||
pScreen->GCPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
||||
pScreen->GCPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||
pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
|
||||
pScreen->PixmapPrivateLen = 1;
|
||||
pScreen->PixmapPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
||||
pScreen->PixmapPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||
pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
|
||||
sizeof(DevUnion)));
|
||||
if (pScreen->WindowPrivateSizes && pScreen->GCPrivateSizes &&
|
||||
pScreen->PixmapPrivateSizes)
|
||||
*pScreen->WindowPrivateSizes = *pScreen->GCPrivateSizes =
|
||||
*pScreen->PixmapPrivateSizes = 0;
|
||||
else {
|
||||
if (!pScreen->WindowPrivateSizes || !pScreen->GCPrivateSizes ||
|
||||
!pScreen->PixmapPrivateSizes) {
|
||||
xfree(pScreen);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -298,10 +298,9 @@ ResetExtensionPrivates()
|
|||
extensionPrivateCount = 1;
|
||||
extensionPrivateLen = 1;
|
||||
xfree(extensionPrivateSizes);
|
||||
extensionPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
||||
extensionPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||
if (!extensionPrivateSizes)
|
||||
return FALSE;
|
||||
*extensionPrivateSizes = 0;
|
||||
totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -358,10 +357,9 @@ ResetClientPrivates()
|
|||
clientPrivateCount = 1;
|
||||
clientPrivateLen = 1;
|
||||
xfree(clientPrivateSizes);
|
||||
clientPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
||||
clientPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||
if (!clientPrivateSizes)
|
||||
return FALSE;
|
||||
*clientPrivateSizes = 0;
|
||||
totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user