1448{
1449 OffsetNumber i,
1450 maxoff;
1451 BOX2DF *unionL = NULL,
1452 *unionR = NULL;
1453 int nbytes;
1454
1455 maxoff = entryvec->n - 1;
1456
1457 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
1458 v->spl_left = (OffsetNumber *) palloc(nbytes);
1459 v->spl_right = (OffsetNumber *) palloc(nbytes);
1460 v->spl_nleft = v->spl_nright = 0;
1461
1462 for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
1463 {
1464 BOX2DF *
cur = (BOX2DF *) DatumGetPointer(entryvec->vector[i].key);
1465
1466 if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
1467 {
1468 v->spl_left[v->spl_nleft] = i;
1469 if (unionL == NULL)
1470 {
1471 unionL = (BOX2DF *) palloc(sizeof(BOX2DF));
1473 }
1474 else
1476
1477 v->spl_nleft++;
1478 }
1479 else
1480 {
1481 v->spl_right[v->spl_nright] = i;
1482 if (unionR == NULL)
1483 {
1484 unionR = (BOX2DF *) palloc(sizeof(BOX2DF));
1486 }
1487 else
1489
1490 v->spl_nright++;
1491 }
1492 }
1493
1494 if (v->spl_ldatum_exists)
1495 adjustBox(unionL, (BOX2DF *) DatumGetPointer(v->spl_ldatum));
1496 v->spl_ldatum = PointerGetDatum(unionL);
1497
1498 if (v->spl_rdatum_exists)
1499 adjustBox(unionR, (BOX2DF *) DatumGetPointer(v->spl_rdatum));
1500 v->spl_rdatum = PointerGetDatum(unionR);
1501
1502 v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1503}
static void adjustBox(BOX2DF *b, BOX2DF *addon)