All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY()
Date: Fri,  8 Jan 2010 16:42:12 -0200	[thread overview]
Message-ID: <1262976136-31852-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1262976136-31852-1-git-send-email-lcapitulino@redhat.com>

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>
---
 qlist.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/qlist.h b/qlist.h
index afdc446..a3261e1 100644
--- a/qlist.h
+++ b/qlist.h
@@ -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);
-- 
1.6.6

  reply	other threads:[~2010-01-08 18:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08 18:42 [Qemu-devel] [PATCH v1 0/5]: Convert pci_info() to QObject Luiz Capitulino
2010-01-08 18:42 ` Luiz Capitulino [this message]
2010-01-08 18:42 ` [Qemu-devel] [PATCH 2/5] QDict: Introduce qdict_get_qdict() Luiz Capitulino
2010-01-08 18:42 ` [Qemu-devel] [PATCH 3/5] PCI: Convert pci_info() to QObject Luiz Capitulino
2010-01-18 17:16   ` Markus Armbruster
2010-01-19 20:27     ` Luiz Capitulino
2010-01-20  7:32       ` Markus Armbruster
2010-01-08 18:42 ` [Qemu-devel] [PATCH 4/5] PCI: do_pci_info(): PCI bridge support Luiz Capitulino
2010-01-18 17:14   ` Markus Armbruster
2010-01-19 20:11     ` Luiz Capitulino
2010-01-08 18:42 ` [Qemu-devel] [PATCH 5/5] PCI: do_pci_info(): PCI bridge devices support Luiz Capitulino
2010-01-18 17:16 ` [Qemu-devel] [PATCH v1 0/5]: Convert pci_info() to QObject Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2010-01-20 16:39 [Qemu-devel] [PATCH v2 " Luiz Capitulino
2010-01-20 16:39 ` [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY() Luiz Capitulino
2010-01-05 20:34 [Qemu-devel] [PATCH v0 0/5]: Convert pci_info() to QObject Luiz Capitulino
2010-01-05 20:34 ` [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY() Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1262976136-31852-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.