| 31 | }; |
| 32 | |
| 33 | void 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 | |
| 59 | static struct oidtree_node *oidtree_lookup(struct oidtree *ot, |
| 60 | const struct object_id *oid) |