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
|
#endif
|
||||||
/* must pre-allocate one private for the new devPrivates support */
|
/* must pre-allocate one private for the new devPrivates support */
|
||||||
dev->nPrivates = 1;
|
dev->nPrivates = 1;
|
||||||
dev->devPrivates = (DevUnion *)xalloc(sizeof(DevUnion));
|
dev->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
|
||||||
if (!dev->devPrivates) {
|
if (!dev->devPrivates) {
|
||||||
xfree(dev);
|
xfree(dev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dev->devPrivates[0].ptr = NULL;
|
|
||||||
|
|
||||||
dev->unwrapProc = NULL;
|
dev->unwrapProc = NULL;
|
||||||
dev->coreEvents = TRUE;
|
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 */
|
/* must pre-allocate one private for the new devPrivates support */
|
||||||
pScreen->WindowPrivateLen = 1;
|
pScreen->WindowPrivateLen = 1;
|
||||||
pScreen->WindowPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
pScreen->WindowPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||||
pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
|
pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
|
||||||
pScreen->GCPrivateLen = 1;
|
pScreen->GCPrivateLen = 1;
|
||||||
pScreen->GCPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
pScreen->GCPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||||
pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
|
pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
|
||||||
pScreen->PixmapPrivateLen = 1;
|
pScreen->PixmapPrivateLen = 1;
|
||||||
pScreen->PixmapPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
pScreen->PixmapPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||||
pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
|
pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
|
||||||
sizeof(DevUnion)));
|
sizeof(DevUnion)));
|
||||||
if (pScreen->WindowPrivateSizes && pScreen->GCPrivateSizes &&
|
if (!pScreen->WindowPrivateSizes || !pScreen->GCPrivateSizes ||
|
||||||
pScreen->PixmapPrivateSizes)
|
!pScreen->PixmapPrivateSizes) {
|
||||||
*pScreen->WindowPrivateSizes = *pScreen->GCPrivateSizes =
|
|
||||||
*pScreen->PixmapPrivateSizes = 0;
|
|
||||||
else {
|
|
||||||
xfree(pScreen);
|
xfree(pScreen);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,10 +298,9 @@ ResetExtensionPrivates()
|
||||||
extensionPrivateCount = 1;
|
extensionPrivateCount = 1;
|
||||||
extensionPrivateLen = 1;
|
extensionPrivateLen = 1;
|
||||||
xfree(extensionPrivateSizes);
|
xfree(extensionPrivateSizes);
|
||||||
extensionPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
extensionPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||||
if (!extensionPrivateSizes)
|
if (!extensionPrivateSizes)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
*extensionPrivateSizes = 0;
|
|
||||||
totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
|
totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -358,10 +357,9 @@ ResetClientPrivates()
|
||||||
clientPrivateCount = 1;
|
clientPrivateCount = 1;
|
||||||
clientPrivateLen = 1;
|
clientPrivateLen = 1;
|
||||||
xfree(clientPrivateSizes);
|
xfree(clientPrivateSizes);
|
||||||
clientPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
|
clientPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
|
||||||
if (!clientPrivateSizes)
|
if (!clientPrivateSizes)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
*clientPrivateSizes = 0;
|
|
||||||
totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
|
totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue