aboutsummaryrefslogtreecommitdiff
path: root/qlist.c
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2012-08-15 13:45:42 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-16 13:41:15 -0500
commita86a4c2f7b7f0b72816ea1c219d8140699b6665b (patch)
tree8fcb1828a7cc1c76d6074031383db4cb8947833f /qlist.c
parent5a4d701acde890a5ca134236424ece45545f70c7 (diff)
downloadqemu-a86a4c2f7b7f0b72816ea1c219d8140699b6665b.zip
qemu-a86a4c2f7b7f0b72816ea1c219d8140699b6665b.tar.gz
qemu-a86a4c2f7b7f0b72816ea1c219d8140699b6665b.tar.bz2
qlist: add qlist_size()
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qlist.c')
-rw-r--r--qlist.c13
1 files changed, 13 insertions, 0 deletions
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
*/