diff options
Diffstat (limited to 'libX11/src/Region.c')
-rw-r--r-- | libX11/src/Region.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/libX11/src/Region.c b/libX11/src/Region.c index d3d431a64..d5dd5561f 100644 --- a/libX11/src/Region.c +++ b/libX11/src/Region.c @@ -142,7 +142,7 @@ XCreateRegion(void) if (! (temp = Xmalloc(sizeof( REGION )))) return (Region) NULL; if (! (temp->rects = Xmalloc(sizeof( BOX )))) { - Xfree((char *) temp); + Xfree(temp); return (Region) NULL; } temp->numRects = 0; @@ -507,7 +507,7 @@ XIntersectRegion( return 1; } -static void +static int miRegionCopy( register Region dstrgn, register Region rgn) @@ -525,7 +525,8 @@ miRegionCopy( rgn->numRects * (sizeof(BOX))); if (! dstrgn->rects) { Xfree(prevRects); - return; + dstrgn->size = 0; + return 0; } } dstrgn->size = rgn->numRects; @@ -539,6 +540,7 @@ miRegionCopy( memcpy((char *) dstrgn->rects, (char *) rgn->rects, (int) (rgn->numRects * sizeof(BOX))); } + return 1; } /*====================================================================== @@ -978,11 +980,12 @@ miRegionOp( if (REGION_NOT_EMPTY(newReg)) { BoxPtr prev_rects = newReg->rects; - newReg->size = newReg->numRects; newReg->rects = Xrealloc (newReg->rects, - sizeof(BoxRec) * newReg->size); + sizeof(BoxRec) * newReg->numRects); if (! newReg->rects) newReg->rects = prev_rects; + else + newReg->size = newReg->numRects; } else { @@ -991,11 +994,11 @@ miRegionOp( * the region is empty */ newReg->size = 1; - Xfree((char *) newReg->rects); + Xfree(newReg->rects); newReg->rects = Xmalloc(sizeof(BoxRec)); } } - Xfree ((char *) oldRects); + Xfree (oldRects); return; } @@ -1150,7 +1153,7 @@ XUnionRegion( if ( (reg1 == reg2) || (!(reg1->numRects)) ) { if (newReg != reg2) - miRegionCopy(newReg, reg2); + return miRegionCopy(newReg, reg2); return 1; } @@ -1160,7 +1163,7 @@ XUnionRegion( if (!(reg2->numRects)) { if (newReg != reg1) - miRegionCopy(newReg, reg1); + return miRegionCopy(newReg, reg1); return 1; } @@ -1174,7 +1177,7 @@ XUnionRegion( (reg1->extents.y2 >= reg2->extents.y2)) { if (newReg != reg1) - miRegionCopy(newReg, reg1); + return miRegionCopy(newReg, reg1); return 1; } @@ -1188,7 +1191,7 @@ XUnionRegion( (reg2->extents.y2 >= reg1->extents.y2)) { if (newReg != reg2) - miRegionCopy(newReg, reg2); + return miRegionCopy(newReg, reg2); return 1; } @@ -1429,8 +1432,7 @@ XSubtractRegion( if ( (!(regM->numRects)) || (!(regS->numRects)) || (!EXTENTCHECK(®M->extents, ®S->extents)) ) { - miRegionCopy(regD, regM); - return 1; + return miRegionCopy(regD, regM); } miRegionOp (regD, regM, regS, miSubtractO, |