diff --git a/include/grpc/support/avl.h b/include/grpc/support/avl.h index 5c222e6c29e..d462f52bfe0 100644 --- a/include/grpc/support/avl.h +++ b/include/grpc/support/avl.h @@ -77,7 +77,7 @@ gpr_avl gpr_avl_ref(gpr_avl avl); are no references left */ void gpr_avl_unref(gpr_avl avl); /** return a new tree with (key, value) added to avl. - implicitly unrefs avl to allow easy chaining. + implicitly unrefs avl to allow easy chaining. if key exists in avl, the new tree's key entry updated (i.e. a duplicate is not created) */ gpr_avl gpr_avl_add(gpr_avl avl, void *key, void *value); diff --git a/src/core/support/avl.c b/src/core/support/avl.c index 28b4eb9f421..9734c9987fe 100644 --- a/src/core/support/avl.c +++ b/src/core/support/avl.c @@ -206,9 +206,9 @@ static gpr_avl_node *add(const gpr_avl_vtable *vtable, gpr_avl_node *node, if (cmp == 0) { return new_node(key, value, ref_node(node->left), ref_node(node->right)); } else if (cmp > 0) { - return rebalance(vtable, vtable->copy_key(node->key), - vtable->copy_value(node->value), - add(vtable, node->left, key, value), ref_node(node->right)); + return rebalance( + vtable, vtable->copy_key(node->key), vtable->copy_value(node->value), + add(vtable, node->left, key, value), ref_node(node->right)); } else { return rebalance(vtable, vtable->copy_key(node->key), vtable->copy_value(node->value), ref_node(node->left), @@ -253,11 +253,13 @@ static gpr_avl_node *remove(const gpr_avl_vtable *vtable, gpr_avl_node *node, } else if (node->left->height < node->right->height) { gpr_avl_node *h = in_order_head(node->right); return rebalance(vtable, vtable->copy_key(h->key), - vtable->copy_value(h->value), ref_node(node->left), remove(vtable, node->right, h->key)); + vtable->copy_value(h->value), ref_node(node->left), + remove(vtable, node->right, h->key)); } else { gpr_avl_node *h = in_order_tail(node->left); - return rebalance(vtable, vtable->copy_key(h->key), - vtable->copy_value(h->value), remove(vtable, node->left, h->key), ref_node(node->right)); + return rebalance( + vtable, vtable->copy_key(h->key), vtable->copy_value(h->value), + remove(vtable, node->left, h->key), ref_node(node->right)); } } else if (cmp > 0) { return rebalance(vtable, vtable->copy_key(node->key),