MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / join

Function join

dep/hfsutils/libhfs/node.c:391–421  ·  view source on GitHub ↗

* NAME: join() * DESCRIPTION: combine two nodes into a single node */

Source from the content-addressed store, hash-verified

389 * DESCRIPTION: combine two nodes into a single node
390 */
391static
392int 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
419fail:
420 return -1;
421}
422
423/*
424 * NAME: node->delete()

Callers 1

n_deleteFunction · 0.70

Calls 2

bt_putnodeFunction · 0.85
n_freeFunction · 0.85

Tested by

no test coverage detected