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

Function oidtree_insert

oidtree.c:33–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31};
32
33void oidtree_insert(struct oidtree *ot, const struct object_id *oid,
34 void *data)
35{
36 struct oidtree_node *on;
37 struct cb_node *node;
38
39 if (!oid->algo)
40 BUG("oidtree_insert requires oid->algo");
41
42 on = mem_pool_alloc(&ot->mem_pool, sizeof(*on));
43 oidcpy(&on->key, oid);
44 on->data = data;
45
46 /*
47 * n.b. Current callers won't get us duplicates, here. If a
48 * future caller causes duplicates, there'll be a small leak
49 * that won't be freed until oidtree_clear. Currently it's not
50 * worth maintaining a free list
51 */
52 node = cb_insert(&ot->tree, &on->base, sizeof(*oid));
53 if (node) {
54 struct oidtree_node *preexisting = container_of(node, struct oidtree_node, base);
55 preexisting->data = data;
56 }
57}
58
59static struct oidtree_node *oidtree_lookup(struct oidtree *ot,
60 const struct object_id *oid)

Callers 5

insert_loose_mapFunction · 0.85
fill_tree_locFunction · 0.85
append_loose_objectFunction · 0.85

Calls 3

mem_pool_allocFunction · 0.85
oidcpyFunction · 0.85
cb_insertFunction · 0.85

Tested by 1