提交 03f2f93a 编写于 作者: S Suzuki K. Poulose 提交者: Arnaldo Carvalho de Melo

Account the nr_entries in rblist properly

The nr_entries in rblist is never decremented when an element
is deleted. Also, use rblist__remove_node to delete a node in
rblist__delete(). This would keep the nr_entries sane.
Signed-off-by: NSuzuki K. Poulose <suzuki@in.ibm.com>
Acked-by: NDavid S. Ahern <dsahern@gmail.com>
Cc: David S. Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/20120831070834.14806.87398.stgit@suzukikp.in.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 68e94f4e
......@@ -44,6 +44,7 @@ int rblist__add_node(struct rblist *rblist, const void *new_entry)
void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node)
{
rb_erase(rb_node, &rblist->entries);
--rblist->nr_entries;
rblist->node_delete(rblist, rb_node);
}
......@@ -87,8 +88,7 @@ void rblist__delete(struct rblist *rblist)
while (next) {
pos = next;
next = rb_next(pos);
rb_erase(pos, &rblist->entries);
rblist->node_delete(rblist, pos);
rblist__remove_node(rblist, pos);
}
free(rblist);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册