qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-1.2 v2 1/3] qlist: add qlist_size()
@ 2012-08-15 17:56 Michael Roth
  2012-08-15 17:56 ` [Qemu-devel] [PATCH for-1.2 v2 2/3] json-parser: don't replicate tokens at each level of recursion Michael Roth
  2012-08-15 17:57 ` [Qemu-devel] [PATCH for-1.2 v2 3/3] check-qjson: add test for large JSON objects Michael Roth
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Roth @ 2012-08-15 17:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, 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] 5+ messages in thread

end of thread, other threads:[~2012-08-15 18:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 17:56 [Qemu-devel] [PATCH for-1.2 v2 1/3] qlist: add qlist_size() Michael Roth
2012-08-15 17:56 ` [Qemu-devel] [PATCH for-1.2 v2 2/3] json-parser: don't replicate tokens at each level of recursion Michael Roth
2012-08-15 18:09   ` Eric Blake
2012-08-15 18:44     ` Michael Roth
2012-08-15 17:57 ` [Qemu-devel] [PATCH for-1.2 v2 3/3] check-qjson: add test for large JSON objects Michael Roth

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).