static ngx_inline ngx_rbtree_node_t *
ngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
{
    while (node->left != sentinel) {
        node = node->left;
    }
    return node;
}
['static void\nngx_resolver_cleanup_tree(ngx_resolver_t *r, ngx_rbtree_t *tree)\n{\n    ngx_resolver_ctx_t   *ctx, *next;\n    ngx_resolver_node_t  *rn;\n    while (tree->root != tree->sentinel) {\n        rn = (ngx_resolver_node_t *) ngx_rbtree_min(tree->root, tree->sentinel);\n        ngx_queue_remove(&rn->queue);\n        for (ctx = rn->waiting; ctx; ctx = next) {\n            next = ctx->next;\n            if (ctx->event) {\n                ngx_resolver_free(r, ctx->event);\n            }\n            ngx_resolver_free(r, ctx);\n        }\n        ngx_rbtree_delete(tree, &rn->node);\n        ngx_resolver_free_node(r, rn);\n    }\n}', 'static void\nngx_resolver_free_node(ngx_resolver_t *r, ngx_resolver_node_t *rn)\n{\n    if (rn->query) {\n        ngx_resolver_free_locked(r, rn->query);\n    }\n    if (rn->name) {\n        ngx_resolver_free_locked(r, rn->name);\n    }\n    if (rn->cnlen) {\n        ngx_resolver_free_locked(r, rn->u.cname);\n    }\n    if (rn->naddrs > 1) {\n        ngx_resolver_free_locked(r, rn->u.addrs);\n    }\n    ngx_resolver_free_locked(r, rn);\n}', 'static void\nngx_resolver_free_locked(ngx_resolver_t *r, void *p)\n{\n    ngx_free(p);\n}', 'static ngx_inline ngx_rbtree_node_t *\nngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)\n{\n    while (node->left != sentinel) {\n        node = node->left;\n    }\n    return node;\n}']