MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / n_search

Function n_search

dep/hfsutils/libhfs/node.c:193–220  ·  view source on GitHub ↗

* NAME: node->search() * DESCRIPTION: locate a record in a node, or the record it should follow */

Source from the content-addressed store, hash-verified

191 * DESCRIPTION: locate a record in a node, or the record it should follow
192 */
193int n_search(node *np, const byte *pkey)
194{
195 const btree *bt = np->bt;
196 byte key1[HFS_MAX_KEYLEN], key2[HFS_MAX_KEYLEN];
197 int i, comp = -1;
198
199 bt->keyunpack(pkey, key2);
200
201 for (i = np->nd.ndNRecs; i--; )
202 {
203 const byte *rec;
204
205 rec = HFS_NODEREC(*np, i);
206
207 if (HFS_RECKEYLEN(rec) == 0)
208 continue; /* deleted record */
209
210 bt->keyunpack(rec, key1);
211 comp = bt->keycompare(key1, key2);
212
213 if (comp <= 0)
214 break;
215 }
216
217 np->rnum = i;
218
219 return comp == 0;
220}
221
222/*
223 * NAME: node->index()

Callers 5

splitFunction · 0.85
insertxFunction · 0.85
bt_insertFunction · 0.85
deletexFunction · 0.85
bt_searchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected