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>
This commit is contained in:
parent
c6b8b78a29
commit
28e8a3c475
|
@ -96,7 +96,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
|
|||
pExaPixmap->use_gpu_copy = FALSE;
|
||||
|
||||
if (w == 1 && h == 1) {
|
||||
pExaPixmap->sys_ptr = malloc(paddedWidth);
|
||||
pExaPixmap->sys_ptr = calloc(1, paddedWidth);
|
||||
|
||||
/* Set up damage tracking */
|
||||
pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
|
||||
|
|
|
@ -238,7 +238,7 @@ exaOffscreenAlloc(ScreenPtr pScreen, int size, int align,
|
|||
|
||||
/* save extra space in new area */
|
||||
if (real_size < area->size) {
|
||||
ExaOffscreenArea *new_area = malloc(sizeof(ExaOffscreenArea));
|
||||
ExaOffscreenArea *new_area = calloc(1, sizeof(ExaOffscreenArea));
|
||||
|
||||
if (!new_area)
|
||||
return NULL;
|
||||
|
@ -634,11 +634,9 @@ Bool
|
|||
exaOffscreenInit(ScreenPtr pScreen)
|
||||
{
|
||||
ExaScreenPriv(pScreen);
|
||||
ExaOffscreenArea *area;
|
||||
|
||||
/* Allocate a big free area */
|
||||
area = malloc(sizeof(ExaOffscreenArea));
|
||||
|
||||
ExaOffscreenArea *area = calloc(1, sizeof(ExaOffscreenArea));
|
||||
if (!area)
|
||||
return FALSE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue