dix: region: turn xfreeData() into inline func and add checks

For type-safety turn xfreeData() macro into an inline function.
Also adding some checks against accidentially free()'ing global data.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-05-08 16:11:58 +02:00
parent 765cb85350
commit 4d3d4a34ec

View File

@ -170,7 +170,12 @@ Equipment Corporation.
// note: we really need to check for size, because when it's zero, then data
// might point to RegionBrokenData (.data segment), which we must not free()
// (this also can create analyzer false alarms)
#define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
static inline void xfreeData(RegionPtr reg) {
if (reg && reg->data && reg->data->size &&
reg->data != &RegionBrokenData &&
reg->data != &RegionEmptyData)
free(reg->data);
}
#define RECTALLOC_BAIL(pReg,n,bail) \
if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \