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>
This commit is contained in:
parent
900ddb69a2
commit
a6ec907b22
|
@ -1638,7 +1638,6 @@ miDamageDestroy(DamagePtr pDamage)
|
||||||
Bool
|
Bool
|
||||||
DamageSetup(ScreenPtr pScreen)
|
DamageSetup(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
DamageScrPrivPtr pScrPriv;
|
|
||||||
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
|
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
|
||||||
|
|
||||||
const DamageScreenFuncsRec miFuncs = {
|
const DamageScreenFuncsRec miFuncs = {
|
||||||
|
@ -1661,7 +1660,7 @@ DamageSetup(ScreenPtr pScreen)
|
||||||
if (!dixRegisterPrivateKey(&damageWinPrivateKeyRec, PRIVATE_WINDOW, 0))
|
if (!dixRegisterPrivateKey(&damageWinPrivateKeyRec, PRIVATE_WINDOW, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pScrPriv = malloc(sizeof(DamageScrPrivRec));
|
DamageScrPrivPtr pScrPriv = calloc(1, sizeof(DamageScrPrivRec));
|
||||||
if (!pScrPriv)
|
if (!pScrPriv)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ RootlessUpdateScreenPixmap(ScreenPtr pScreen)
|
||||||
free(s->pixmap_data);
|
free(s->pixmap_data);
|
||||||
|
|
||||||
s->pixmap_data_size = rowbytes;
|
s->pixmap_data_size = rowbytes;
|
||||||
s->pixmap_data = malloc(s->pixmap_data_size);
|
s->pixmap_data = calloc(1, s->pixmap_data_size);
|
||||||
if (s->pixmap_data == NULL)
|
if (s->pixmap_data == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -600,8 +600,6 @@ RootlessWakeupHandler(void *data, int result)
|
||||||
static Bool
|
static Bool
|
||||||
RootlessAllocatePrivates(ScreenPtr pScreen)
|
RootlessAllocatePrivates(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
RootlessScreenRec *s;
|
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey
|
if (!dixRegisterPrivateKey
|
||||||
(&rootlessGCPrivateKeyRec, PRIVATE_GC, sizeof(RootlessGCRec)))
|
(&rootlessGCPrivateKeyRec, PRIVATE_GC, sizeof(RootlessGCRec)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -613,17 +611,11 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
|
||||||
(&rootlessWindowOldPixmapPrivateKeyRec, PRIVATE_WINDOW, 0))
|
(&rootlessWindowOldPixmapPrivateKeyRec, PRIVATE_WINDOW, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
s = malloc(sizeof(RootlessScreenRec));
|
RootlessScreenRec *s = calloc(1, sizeof(RootlessScreenRec));
|
||||||
if (!s)
|
if (!s)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
SETSCREENREC(pScreen, s);
|
SETSCREENREC(pScreen, s);
|
||||||
|
|
||||||
s->pixmap_data = NULL;
|
|
||||||
s->pixmap_data_size = 0;
|
|
||||||
|
|
||||||
s->redisplay_timer = NULL;
|
|
||||||
s->redisplay_timer_set = FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,6 @@ static RootlessWindowRec *
|
||||||
RootlessEnsureFrame(WindowPtr pWin)
|
RootlessEnsureFrame(WindowPtr pWin)
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||||
RootlessWindowRec *winRec;
|
|
||||||
RegionRec shape;
|
RegionRec shape;
|
||||||
RegionPtr pShape = NULL;
|
RegionPtr pShape = NULL;
|
||||||
|
|
||||||
|
@ -376,8 +375,7 @@ RootlessEnsureFrame(WindowPtr pWin)
|
||||||
if (pWin->drawable.class != InputOutput)
|
if (pWin->drawable.class != InputOutput)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
winRec = malloc(sizeof(RootlessWindowRec));
|
RootlessWindowRec *winRec = calloc(1, sizeof(RootlessWindowRec));
|
||||||
|
|
||||||
if (!winRec)
|
if (!winRec)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,6 @@ static void shadowCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *un
|
||||||
Bool
|
Bool
|
||||||
shadowSetup(ScreenPtr pScreen)
|
shadowSetup(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
shadowBufPtr pBuf;
|
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0))
|
if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -119,7 +118,7 @@ shadowSetup(ScreenPtr pScreen)
|
||||||
if (!DamageSetup(pScreen))
|
if (!DamageSetup(pScreen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pBuf = malloc(sizeof(shadowBufRec));
|
shadowBufPtr pBuf = calloc(1, sizeof(shadowBufRec));
|
||||||
if (!pBuf)
|
if (!pBuf)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
pBuf->pDamage = DamageCreate((DamageReportFunc) NULL,
|
pBuf->pDamage = DamageCreate((DamageReportFunc) NULL,
|
||||||
|
|
Loading…
Reference in New Issue