From e87d41a91d05b55e8f6d3e22ec98da309b945c2a Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 10 Apr 2025 19:56:18 +0200 Subject: [PATCH] include: 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 --- include/regionstr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/regionstr.h b/include/regionstr.h index a42290124..78d071cc2 100644 --- a/include/regionstr.h +++ b/include/regionstr.h @@ -144,7 +144,7 @@ RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size) size_t rgnSize; (_pReg)->extents = RegionEmptyBox; if (((_size) > 1) && ((rgnSize = RegionSizeof(_size)) > 0) && - (((_pReg)->data = (RegDataPtr) malloc(rgnSize)) != NULL)) { + (((_pReg)->data = (RegDataPtr) calloc(1, rgnSize)) != NULL)) { (_pReg)->data->size = (_size); (_pReg)->data->numRects = 0; }