From patchwork Tue Aug 21 17:05:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 179135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 50A072C00B2 for ; Wed, 22 Aug 2012 04:41:39 +1000 (EST) Received: from localhost ([::1]:42997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rvI-0000Lq-2R for incoming@patchwork.ozlabs.org; Tue, 21 Aug 2012 13:07:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rud-0007gy-90 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3rua-0002nK-Sq for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:43 -0400 Received: from mail-gg0-f173.google.com ([209.85.161.173]:58041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rua-0002fG-P5 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:40 -0400 Received: by mail-gg0-f173.google.com with SMTP id a5so32818ggn.4 for ; Tue, 21 Aug 2012 10:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=sK6RexKZwwddyyD/I19hugcdG8ONaPOX75smC0Hr6Wg=; b=fjEXGNMbZ0yGpBGAXEqb/H9Ha7UzP8YpL21V73OqVe+FLHGhBatKBbsYcAaxzwqhwx aPOMD4pYkPhqGAt2Irjjx67wtj9TjQfTwzaTyJm4B0LfyYzahqGMChASQ95zpv3/u9gI f4+oLcqx7/UHO6p3R1F+SGRdy8OLIcljaNGRxE1YGClW3Fr0/KxNLqn9MCP1bCjPloLM RuLXywdHAOxu7BEdtW85c4ncYFYoxp+qGHBsg/L/OLkRSJZ3SmSjqehSwyG+4nqEW2Gt B9pHV/btCcZET/boXB9omgt0nsx1VTtb8Cd9vrneioShEt6l5l5+0k9ToNwscQ6HSx3M rFJg== Received: by 10.50.88.229 with SMTP id bj5mr14074348igb.21.1345568800367; Tue, 21 Aug 2012 10:06:40 -0700 (PDT) Received: from loki.morrigu.org (cpe-72-179-62-111.austin.res.rr.com. [72.179.62.111]) by mx.google.com with ESMTPS id xm2sm3717964igb.3.2012.08.21.10.06.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Aug 2012 10:06:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2012 12:05:48 -0500 Message-Id: <1345568757-14365-15-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1345568757-14365-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1345568757-14365-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.173 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 14/23] qlist: add qlist_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Michael Roth Reviewed-by: Eric Blake Signed-off-by: Michael Roth Signed-off-by: Anthony Liguori (cherry picked from commit a86a4c2f7b7f0b72816ea1c219d8140699b6665b) Signed-off-by: Michael Roth --- qlist.c | 13 +++++++++++++ qlist.h | 1 + 2 files changed, 14 insertions(+) diff --git a/qlist.c b/qlist.c index 88498b1..b48ec5b 100644 --- a/qlist.c +++ b/qlist.c @@ -124,6 +124,19 @@ int qlist_empty(const QList *qlist) return QTAILQ_EMPTY(&qlist->head); } +static void qlist_size_iter(QObject *obj, void *opaque) +{ + size_t *count = opaque; + (*count)++; +} + +size_t qlist_size(const QList *qlist) +{ + size_t count = 0; + qlist_iter(qlist, qlist_size_iter, &count); + return count; +} + /** * qobject_to_qlist(): Convert a QObject into a QList */ diff --git a/qlist.h b/qlist.h index d426bd4..ae776f9 100644 --- a/qlist.h +++ b/qlist.h @@ -49,6 +49,7 @@ void qlist_iter(const QList *qlist, QObject *qlist_pop(QList *qlist); QObject *qlist_peek(QList *qlist); int qlist_empty(const QList *qlist); +size_t qlist_size(const QList *qlist); QList *qobject_to_qlist(const QObject *obj); static inline const QListEntry *qlist_first(const QList *qlist)