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>
This commit is contained in:
parent
7a8b8e110e
commit
c4c5f03cb7
|
@ -260,7 +260,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))
|
||||||
|
@ -269,7 +268,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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue