Avoid sequences of malloc(0) / free() by checking the length.
This has an impact on heap fragmentation. Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
This commit is contained in:
parent
15a413e11d
commit
b2d96b5cd4
|
@ -404,7 +404,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
|||
int i;
|
||||
BoxPtr pbox;
|
||||
xRectangle *prect;
|
||||
int numRects;
|
||||
int numRects, regionnumrects;
|
||||
|
||||
/*
|
||||
* Distance from screen to destination drawable, use this
|
||||
|
@ -508,7 +508,10 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
|||
gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
|
||||
}
|
||||
|
||||
prect = xallocarray(RegionNumRects(prgn), sizeof(xRectangle));
|
||||
regionnumrects = RegionNumRects(prgn);
|
||||
if (regionnumrects == 0)
|
||||
return;
|
||||
prect = xallocarray(regionnumrects, sizeof(xRectangle));
|
||||
if (!prect)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue