PRINTF("Allocating more regionrect space...\n");
static void RealQueryRects( HRGN              hrgn,                            HPS               hps,                            nsRegionRectSet **aRects,                            CGetRects        *aGetRects){   BOOL isRECTL = aRects ? FALSE : TRUE;   // right, this is far too complicated.  What we want is a function to   // query how many rectangles we need before we start...   RECTL   rects[ 10];   RGNRECT rgnRect = { 1, 10, 0, RECTDIR_LFRT_TOPBOT };   for( ;;)   {      // get a batch of rectangles      GpiQueryRegionRects( hps, hrgn, 0, &rgnRect, rects);      // call them out      for( PRUint32 i = 0; i < rgnRect.crcReturned; i++)      {         if( isRECTL)         {            aGetRects->add( rects[i]);         }         else         {            // accumulate nsRects in the nsRegionRectSet structure            // first check for space            if( (*aRects)->mNumRects == (*aRects)->mRectsLen)            {               *aRects = (nsRegionRectSet *)                  realloc( *aRects, sizeof( nsRegionRectSet) +                             ((*aRects)->mNumRects + 9) * sizeof(nsRegionRect));               (*aRects)->mRectsLen += 10;#ifdef DEBUG// !! If this happens lots, bump up initial allocation               printf( "Allocating more regionrect space...\n");#endif            }            nsRegionRect *theRect = (*aRects)->mRects + (*aRects)->mNumRects;            theRect->x = rects[i].xLeft;            theRect->y = rects[i].yBottom;            theRect->width = rects[i].xRight - rects[i].xLeft;  // in-ex            theRect->height = rects[i].yTop - rects[i].yBottom;            (*aRects)->mNumRects++;         }      }      // are we done ?      if( rgnRect.crcReturned < rgnRect.crc) break;      // set up for the next batch      rgnRect.ircStart += 10;   }}