From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZtXo-0001BJ-Fg for qemu-devel@nongnu.org; Tue, 26 Jan 2010 17:05:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZtXk-00018Y-QC for qemu-devel@nongnu.org; Tue, 26 Jan 2010 17:05:56 -0500 Received: from [199.232.76.173] (port=42314 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZtXk-00018P-KE for qemu-devel@nongnu.org; Tue, 26 Jan 2010 17:05:52 -0500 Received: from mail-iw0-f188.google.com ([209.85.223.188]:51342) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZtXk-0000nh-6U for qemu-devel@nongnu.org; Tue, 26 Jan 2010 17:05:52 -0500 Received: by mail-iw0-f188.google.com with SMTP id 26so5381269iwn.14 for ; Tue, 26 Jan 2010 14:05:52 -0800 (PST) Message-ID: <4B5F6739.8010805@codemonkey.ws> Date: Tue, 26 Jan 2010 16:05:45 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/4] QList: Introduce QLIST_FOREACH_ENTRY() References: <1264108541-4071-1-git-send-email-lcapitulino@redhat.com> <1264108541-4071-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1264108541-4071-2-git-send-email-lcapitulino@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org On 01/21/2010 03:15 PM, Luiz Capitulino wrote: > 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 > Applied all. Thanks. Regards, Anthony Liguori > --- > 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); >