* NAME: join() * DESCRIPTION: combine two nodes into a single node */
| 389 | * DESCRIPTION: combine two nodes into a single node |
| 390 | */ |
| 391 | static |
| 392 | int join(node *left, node *right, byte *record, int *flag) |
| 393 | { |
| 394 | int i, offset; |
| 395 | |
| 396 | /* copy records and offsets */ |
| 397 | |
| 398 | memcpy(HFS_NODEREC(*left, left->nd.ndNRecs), |
| 399 | HFS_NODEREC(*right, 0), NODEUSED(*right)); |
| 400 | |
| 401 | offset = left->roff[left->nd.ndNRecs] - right->roff[0]; |
| 402 | |
| 403 | for (i = 1; i <= right->nd.ndNRecs; ++i) |
| 404 | left->roff[++left->nd.ndNRecs] = offset + right->roff[i]; |
| 405 | |
| 406 | if (bt_putnode(left) == -1) |
| 407 | goto fail; |
| 408 | |
| 409 | /* eliminate node and update link pointers */ |
| 410 | |
| 411 | if (n_free(right) == -1) |
| 412 | goto fail; |
| 413 | |
| 414 | HFS_SETKEYLEN(record, 0); |
| 415 | *flag = 1; |
| 416 | |
| 417 | return 0; |
| 418 | |
| 419 | fail: |
| 420 | return -1; |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * NAME: node->delete() |
no test coverage detected