QList: Introduce QLIST_FOREACH_ENTRY()

Iterate over QList entries, it's needed to call qlist_entry_obj()
to retrieve the stored QObject.

I'm not sure if it's ok to have this, because it's not as easy as
qlist_iter() and the QListEntry data type is now exposed to the
users, which means we have one more struct to be maintained when
we have libqmp.

Adding anyway, as it's more compact and people are asking for it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Luiz Capitulino 2010-01-21 19:15:38 -02:00 committed by Anthony Liguori
parent 0a7fc983ce
commit 59eb1c85cd
1 changed files with 10 additions and 0 deletions

10
qlist.h
View File

@ -29,6 +29,16 @@ typedef struct QList {
#define qlist_append(qlist, obj) \
qlist_append_obj(qlist, QOBJECT(obj))
#define QLIST_FOREACH_ENTRY(qlist, var) \
for ((var) = ((qlist)->head.tqh_first); \
(var); \
(var) = ((var)->next.tqe_next))
static inline QObject *qlist_entry_obj(const QListEntry *entry)
{
return entry->value;
}
QList *qlist_new(void);
QList *qlist_copy(QList *src);
void qlist_append_obj(QList *qlist, QObject *obj);