MCPcopy Create free account
hub / github.com/GJDuck/e9patch / tfind

Function tfind

examples/stdlib.c:5452–5471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5450}
5451
5452static void *tfind(const void *key, void **root,
5453 int (*compare)(const void *, const void *))
5454{
5455 if (root == NULL)
5456 return NULL;
5457 struct tree_s *t = (struct tree_s *)root;
5458 struct node_s *n = t->root;
5459 int cmp = 0;
5460 while (n != NULL)
5461 {
5462 cmp = compare(key, n->key);
5463 if (cmp < 0)
5464 n = TREE_LEFT(n);
5465 else if (cmp > 0)
5466 n = TREE_RIGHT(n);
5467 else
5468 return (void *)n;
5469 }
5470 return NULL;
5471}
5472static void *pool_tfind(struct malloc_pool_s *pool, const void *key,
5473 void **root, int (*compare)(const void *, const void *))
5474{

Callers 7

internal_functionFunction · 0.85
__libdw_findcu_addrFunction · 0.85
libdw_findcu.cFile · 0.85
__libdw_getsrclinesFunction · 0.85
pool_tfindFunction · 0.85
entryFunction · 0.85
entryFunction · 0.85

Calls 1

compareFunction · 0.70

Tested by

no test coverage detected