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:
parent
765cb85350
commit
4d3d4a34ec
|
@ -170,7 +170,12 @@ Equipment Corporation.
|
||||||
// note: we really need to check for size, because when it's zero, then data
|
// 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()
|
// might point to RegionBrokenData (.data segment), which we must not free()
|
||||||
// (this also can create analyzer false alarms)
|
// (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) \
|
#define RECTALLOC_BAIL(pReg,n,bail) \
|
||||||
if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
|
if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
|
||||||
|
|
Loading…
Reference in New Issue