Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177451
b: refs/heads/master
c: abf5ef7
h: refs/heads/master
i:
  177449: eff5cb1
  177447: a992fd8
v: v3
  • Loading branch information
Masami Hiramatsu authored and Ingo Molnar committed Dec 15, 2009
1 parent 6b6de3a commit f8e6d64
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3e3405906dab00afecd5a16871850a088eba4626
refs/heads/master: abf5ef72477f9fb559a8a034fd6e6c397bb37e1f
34 changes: 34 additions & 0 deletions trunk/tools/perf/util/strlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,39 @@ static inline unsigned int strlist__nr_entries(const struct strlist *self)
return self->nr_entries;
}

/* For strlist iteration */
static inline struct str_node *strlist__first(struct strlist *self)
{
struct rb_node *rn = rb_first(&self->entries);
return rn ? rb_entry(rn, struct str_node, rb_node) : NULL;
}
static inline struct str_node *strlist__next(struct str_node *sn)
{
struct rb_node *rn;
if (!sn)
return NULL;
rn = rb_next(&sn->rb_node);
return rn ? rb_entry(rn, struct str_node, rb_node) : NULL;
}

/**
* strlist_for_each - iterate over a strlist
* @pos: the &struct str_node to use as a loop cursor.
* @self: the &struct strlist for loop.
*/
#define strlist__for_each(pos, self) \
for (pos = strlist__first(self); pos; pos = strlist__next(pos))

/**
* strlist_for_each_safe - iterate over a strlist safe against removal of
* str_node
* @pos: the &struct str_node to use as a loop cursor.
* @n: another &struct str_node to use as temporary storage.
* @self: the &struct strlist for loop.
*/
#define strlist__for_each_safe(pos, n, self) \
for (pos = strlist__first(self), n = strlist__next(pos); pos;\
pos = n, n = strlist__next(n))

int strlist__parse_list(struct strlist *self, const char *s);
#endif /* __PERF_STRLIST_H */

0 comments on commit f8e6d64

Please sign in to comment.