Introduce classes__for_each, that receives an iterator function and a cookie,

so that one can traverse all the classes loaded by classes__load.

Also export classes__find_by_id().

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2006-10-28 23:55:56 -03:00
parent 67b12e237c
commit 6b32c8362b
2 changed files with 15 additions and 1 deletions

View File

@ -52,7 +52,7 @@ struct class *classes__find_by_name(const char *name)
return NULL;
}
static struct class *classes__find_by_id(const struct cu_info *type)
struct class *classes__find_by_id(const struct cu_info *type)
{
struct class *pos;
@ -387,6 +387,16 @@ static void classes__add(struct class *class)
list_add_tail(&class->node, &classes__list);
}
void classes__for_each(int (*iterator)(struct class *class, void *cookie),
void *cookie)
{
struct class *pos;
list_for_each_entry(pos, &classes__list, node)
if (iterator(pos, cookie))
break;
}
void classes__print(const unsigned int tag)
{
struct class *pos;

View File

@ -51,6 +51,10 @@ extern void class__print(struct class *self);
extern int classes__load(const char *filename);
extern struct class *classes__find_by_name(const char *name);
extern struct class *classes__find_by_id(const struct cu_info *type);
extern void classes__print(const unsigned int tag);
extern void classes__for_each(int (*iterator)(struct class *class,
void *cookie),
void *cookie);
#endif /* _PAHOLE_CLASSES_H_ */