| 5476 | } |
| 5477 | |
| 5478 | static void *pool_tdelete(struct malloc_pool_s *pool, const void *key, |
| 5479 | void **root, int (*compare)(const void *, const void *)) |
| 5480 | { |
| 5481 | if (root == NULL) |
| 5482 | return NULL; |
| 5483 | struct tree_s *t = (struct tree_s *)root; |
| 5484 | struct node_s *n = t->root; |
| 5485 | int cmp = 0; |
| 5486 | while (n != NULL) |
| 5487 | { |
| 5488 | cmp = compare(key, n->key); |
| 5489 | if (cmp < 0) |
| 5490 | n = TREE_LEFT(n); |
| 5491 | else if (cmp > 0) |
| 5492 | n = TREE_RIGHT(n); |
| 5493 | else |
| 5494 | { |
| 5495 | struct node_s *parent = TREE_PARENT(n); |
| 5496 | n = tree_remove(t, n); |
| 5497 | pool_free(pool, n); |
| 5498 | return (parent == NULL? (void *)root: parent); |
| 5499 | } |
| 5500 | } |
| 5501 | return NULL; |
| 5502 | } |
| 5503 | static void *tdelete(const void *key, void **root, |
| 5504 | int (*compare)(const void *, const void *)) |
| 5505 | { |
no test coverage detected