From patchwork Fri Jan 8 18:42:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF21FB7BEF for ; Sat, 9 Jan 2010 05:47:27 +1100 (EST) Received: from localhost ([127.0.0.1]:58225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTJqQ-0002Rm-86 for incoming@patchwork.ozlabs.org; Fri, 08 Jan 2010 13:45:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTJn8-0008J6-Nh for qemu-devel@nongnu.org; Fri, 08 Jan 2010 13:42:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTJn3-0008A5-Tf for qemu-devel@nongnu.org; Fri, 08 Jan 2010 13:42:34 -0500 Received: from [199.232.76.173] (port=47704 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTJn3-00089Y-L5 for qemu-devel@nongnu.org; Fri, 08 Jan 2010 13:42:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11104) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTJn3-0007P9-30 for qemu-devel@nongnu.org; Fri, 08 Jan 2010 13:42:29 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08IgScG007449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Jan 2010 13:42:28 -0500 Received: from localhost (vpn-9-144.rdu.redhat.com [10.11.9.144]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o08IgQsL006850; Fri, 8 Jan 2010 13:42:27 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 8 Jan 2010 16:42:12 -0200 Message-Id: <1262976136-31852-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1262976136-31852-1-git-send-email-lcapitulino@redhat.com> References: <1262976136-31852-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);