MCPcopy Create free account
hub / github.com/antirez/ds4 / raxFind

Function raxFind

rax.c:1101–1117  ·  view source on GitHub ↗

Find a key in the rax, returns raxNotFound special void pointer value * if the item was not found, otherwise the value associated with the * item is returned. */

Source from the content-addressed store, hash-verified

1099 * if the item was not found, otherwise the value associated with the
1100 * item is returned. */
1101void *raxFind(rax *rax, unsigned char *s, size_t len) {
1102 raxNode *h;
1103
1104 debugf("### Lookup: %.*s\n", (int)len, s);
1105 int splitpos = 0;
1106 int inline_leaf = 0;
1107 raxNode **parentlink;
1108 size_t i = raxLowWalk(rax,s,len,&h,&parentlink,&splitpos,NULL,&inline_leaf);
1109 if (inline_leaf && i == len) {
1110 void *val;
1111 memcpy(&val,parentlink,sizeof(val));
1112 return val;
1113 }
1114 if (i != len || (h->iscompr && splitpos != 0) || !h->iskey)
1115 return raxNotFound;
1116 return raxGetData(h);
1117}
1118
1119/* Return the memory address where the 'parent' node stores the specified
1120 * 'child' pointer, so that the caller can update the pointer with another

Callers 2

Calls 2

raxLowWalkFunction · 0.85
raxGetDataFunction · 0.85

Tested by

no test coverage detected