MCPcopy Create free account
hub / github.com/git/git / cb_each

Function cb_each

cbtree.c:121–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121int cb_each(struct cb_tree *t, const uint8_t *kpfx, size_t klen,
122 cb_iter fn, void *arg)
123{
124 struct cb_node *p = t->root;
125 struct cb_node *top = p;
126 size_t i = 0;
127 uint8_t *p_key;
128
129 if (!p)
130 return 0; /* empty tree */
131
132 /* Walk tree, maintaining top pointer */
133 while (1 & (uintptr_t)p) {
134 struct cb_node *q = cb_node_of(p);
135 uint8_t c = q->byte < klen ? kpfx[q->byte] : 0;
136 size_t direction = (1 + (q->otherbits | c)) >> 8;
137
138 p = q->child[direction];
139 if (q->byte < klen)
140 top = p;
141 }
142
143 p_key = cb_node_key(t, p);
144 for (i = 0; i < klen; i++) {
145 if (p_key[i] != kpfx[i])
146 return 0; /* "best" match failed */
147 }
148
149 return cb_descend(top, fn, arg);
150}

Callers 1

oidtree_eachFunction · 0.85

Calls 3

cb_node_ofFunction · 0.85
cb_node_keyFunction · 0.85
cb_descendFunction · 0.85

Tested by

no test coverage detected