From 7a8b8e110ef34c262d43c7446a2bae019f9daa0a Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 10 Apr 2025 19:10:22 +0200 Subject: [PATCH] damageext: 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 --- damageext/damageext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/damageext/damageext.c b/damageext/damageext.c index 219cdaad2..ab5c337dc 100644 --- a/damageext/damageext.c +++ b/damageext/damageext.c @@ -233,7 +233,7 @@ static DamageExtPtr DamageExtCreate(DrawablePtr pDrawable, DamageReportLevel level, ClientPtr client, XID id, XID drawable) { - DamageExtPtr pDamageExt = malloc(sizeof(DamageExtRec)); + DamageExtPtr pDamageExt = calloc(1, sizeof(DamageExtRec)); if (!pDamageExt) return NULL;