MCPcopy Create free account
hub / github.com/F-Stack/f-stack / listSearchKey

Function listSearchKey

app/redis-6.2.6/src/adlist.c:291–309  ·  view source on GitHub ↗

Search the list for a node matching a given key. * The match is performed using the 'match' method * set with listSetMatchMethod(). If no 'match' method * is set, the 'value' pointer of every node is directly * compared with the 'key' pointer. * * On success the first matching node pointer is returned * (search starts from head). If no matching node exists * NULL is returned. */

Source from the content-addressed store, hash-verified

289 * (search starts from head). If no matching node exists
290 * NULL is returned. */
291listNode *listSearchKey(list *list, void *key)
292{
293 listIter iter;
294 listNode *node;
295
296 listRewind(list, &iter);
297 while((node = listNext(&iter)) != NULL) {
298 if (list->match) {
299 if (list->match(node->value, key)) {
300 return node;
301 }
302 } else {
303 if (key == node->value) {
304 return node;
305 }
306 }
307 }
308 return NULL;
309}
310
311/* Return the element at the specified zero-based index
312 * where 0 is the head, 1 is the element next to head

Callers 15

ldbRemoveChildFunction · 0.85
pubsubUnsubscribeChannelFunction · 0.85
pubsubSubscribePatternFunction · 0.85
pubsubUnsubscribePatternFunction · 0.85
unwatchAllKeysFunction · 0.85
freeClientFunction · 0.85
unlinkClientFunction · 0.85
freeClientFunction · 0.85
resetCommandFunction · 0.85
ACLSetUserFunction · 0.85
RM_GetSharedAPIFunction · 0.85

Calls 2

listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected