| 57 | } |
| 58 | |
| 59 | static struct oidtree_node *oidtree_lookup(struct oidtree *ot, |
| 60 | const struct object_id *oid) |
| 61 | { |
| 62 | struct object_id k; |
| 63 | size_t klen = sizeof(k); |
| 64 | struct cb_node *node; |
| 65 | |
| 66 | oidcpy(&k, oid); |
| 67 | |
| 68 | if (oid->algo == GIT_HASH_UNKNOWN) |
| 69 | klen -= sizeof(oid->algo); |
| 70 | |
| 71 | /* cb_lookup relies on memcmp on the struct, so order matters: */ |
| 72 | klen += BUILD_ASSERT_OR_ZERO(offsetof(struct object_id, hash) < |
| 73 | offsetof(struct object_id, algo)); |
| 74 | |
| 75 | node = cb_lookup(&ot->tree, (const uint8_t *)&k, klen); |
| 76 | return node ? container_of(node, struct oidtree_node, base) : NULL; |
| 77 | } |
| 78 | |
| 79 | bool oidtree_contains(struct oidtree *ot, const struct object_id *oid) |
| 80 | { |
no test coverage detected