1280{
1281 OffsetNumber i,
1282 maxoff;
1283 BOX2DF *unionL = NULL,
1284 *unionR = NULL;
1285 int nbytes;
1286
1287 maxoff = entryvec->n - 1;
1288
1289 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
1290 v->spl_left = (OffsetNumber *) palloc(nbytes);
1291 v->spl_right = (OffsetNumber *) palloc(nbytes);
1292 v->spl_nleft = v->spl_nright = 0;
1293
1294 for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
1295 {
1296 BOX2DF *
cur = (BOX2DF *) DatumGetPointer(entryvec->vector[i].key);
1297
1298 if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
1299 {
1300 v->spl_left[v->spl_nleft] = i;
1301 if (unionL == NULL)
1302 {
1303 unionL = (BOX2DF *) palloc(sizeof(BOX2DF));
1305 }
1306 else
1308
1309 v->spl_nleft++;
1310 }
1311 else
1312 {
1313 v->spl_right[v->spl_nright] = i;
1314 if (unionR == NULL)
1315 {
1316 unionR = (BOX2DF *) palloc(sizeof(BOX2DF));
1318 }
1319 else
1321
1322 v->spl_nright++;
1323 }
1324 }
1325
1326 if (v->spl_ldatum_exists)
1327 adjustBox(unionL, (BOX2DF *) DatumGetPointer(v->spl_ldatum));
1328 v->spl_ldatum = BoxPGetDatum(unionL);
1329
1330 if (v->spl_rdatum_exists)
1331 adjustBox(unionR, (BOX2DF *) DatumGetPointer(v->spl_rdatum));
1332 v->spl_rdatum = BoxPGetDatum(unionR);
1333
1334 v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1335}
static void adjustBox(BOX2DF *b, BOX2DF *addon)