qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-1.2 v3 1/3] qlist: add qlist_size()
@ 2012-08-15 18:45 Michael Roth
  2012-08-15 18:45 ` [Qemu-devel] [PATCH for-1.2 v3 2/3] json-parser: don't replicate tokens at each level of recursion Michael Roth
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Michael Roth @ 2012-08-15 18:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, eblake, armbru, lcapitulino


Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 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)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-08-16 19:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 18:45 [Qemu-devel] [PATCH for-1.2 v3 1/3] qlist: add qlist_size() Michael Roth
2012-08-15 18:45 ` [Qemu-devel] [PATCH for-1.2 v3 2/3] json-parser: don't replicate tokens at each level of recursion Michael Roth
2012-08-15 20:04   ` Eric Blake
2012-08-15 20:48     ` Michael Roth
2012-08-16 14:11   ` Luiz Capitulino
2012-08-16 19:17     ` Michael Roth
2012-08-15 18:45 ` [Qemu-devel] [PATCH for-1.2 v3 3/3] check-qjson: add test for large JSON objects Michael Roth
2012-08-15 19:52 ` [Qemu-devel] [PATCH for-1.2 v3 1/3] qlist: add qlist_size() Eric Blake
2012-08-15 20:31   ` Michael Roth
2012-08-16 13:40 ` Luiz Capitulino
2012-08-16 19:23   ` Michael Roth
2012-08-16 19:29     ` Luiz Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).