提交 33fec3e3 编写于 作者: J Jin Yao 提交者: Arnaldo Carvalho de Melo

perf rblist: Create rblist__exit() function

Currently we have a rblist__delete() which is used to delete a rblist.
While rblist__delete() will free the pointer of rblist at the end.

It's an inconvenience for the user to delete a rblist which is not
allocated by something like malloc(). For example, the rblist is
embedded in a larger data structure.

This patch creates a new function rblist__exit() which is similar to
rblist__delete() but it will not free the pointer of rblist.
Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
Acked-by: NJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512125856-22056-2-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 35a8a148
......@@ -101,16 +101,21 @@ void rblist__init(struct rblist *rblist)
return;
}
void rblist__exit(struct rblist *rblist)
{
struct rb_node *pos, *next = rb_first(&rblist->entries);
while (next) {
pos = next;
next = rb_next(pos);
rblist__remove_node(rblist, pos);
}
}
void rblist__delete(struct rblist *rblist)
{
if (rblist != NULL) {
struct rb_node *pos, *next = rb_first(&rblist->entries);
while (next) {
pos = next;
next = rb_next(pos);
rblist__remove_node(rblist, pos);
}
rblist__exit(rblist);
free(rblist);
}
}
......
......@@ -29,6 +29,7 @@ struct rblist {
};
void rblist__init(struct rblist *rblist);
void rblist__exit(struct rblist *rblist);
void rblist__delete(struct rblist *rblist);
int rblist__add_node(struct rblist *rblist, const void *new_entry);
void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册