MCPcopy Index your code
hub / github.com/git/git / tree_insert

Function tree_insert

reftable/tree.c:29–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29struct tree_node *tree_insert(struct tree_node **rootp,
30 void *key,
31 int (*compare)(const void *, const void *))
32{
33 int res;
34
35 if (!*rootp) {
36 struct tree_node *n;
37
38 REFTABLE_CALLOC_ARRAY(n, 1);
39 if (!n)
40 return NULL;
41
42 n->key = key;
43 *rootp = n;
44 return *rootp;
45 }
46
47 res = compare(key, (*rootp)->key);
48 if (res < 0)
49 return tree_insert(&(*rootp)->left, key, compare);
50 else if (res > 0)
51 return tree_insert(&(*rootp)->right, key, compare);
52 return *rootp;
53}
54
55void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
56 void *arg)

Callers 3

writer_index_hashFunction · 0.85

Calls 1

compareFunction · 0.50

Tested by 2