diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-08-04 13:58:28 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-04 13:58:28 +0200 |
commit | e16852cfc5580b88cb327413ab8c89375f380592 (patch) | |
tree | 67e7d5b84e2602986f2da689625e5a25d7af7bb4 /tools/perf/util/strlist.c | |
parent | bdff78707f3ce47e891f3201c9666122a70556ce (diff) | |
parent | 74e7ff8c50b6b022e6ffaa736b16a4dc161d3eaf (diff) |
Merge branch 'tracing/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/urgent
Diffstat (limited to 'tools/perf/util/strlist.c')
-rw-r--r-- | tools/perf/util/strlist.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c index 025a78edfffe..7ad38171dc2b 100644 --- a/tools/perf/util/strlist.c +++ b/tools/perf/util/strlist.c @@ -64,6 +64,7 @@ int strlist__add(struct strlist *self, const char *new_entry) rb_link_node(&sn->rb_node, parent, p); rb_insert_color(&sn->rb_node, &self->entries); + ++self->nr_entries; return 0; } @@ -155,8 +156,9 @@ struct strlist *strlist__new(bool dupstr, const char *slist) struct strlist *self = malloc(sizeof(*self)); if (self != NULL) { - self->entries = RB_ROOT; - self->dupstr = dupstr; + self->entries = RB_ROOT; + self->dupstr = dupstr; + self->nr_entries = 0; if (slist && strlist__parse_list(self, slist) != 0) goto out_error; } @@ -182,3 +184,17 @@ void strlist__delete(struct strlist *self) free(self); } } + +struct str_node *strlist__entry(const struct strlist *self, unsigned int idx) +{ + struct rb_node *nd; + + for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { + struct str_node *pos = rb_entry(nd, struct str_node, rb_node); + + if (!idx--) + return pos; + } + + return NULL; +} |