[Spice-devel] [PATCH 5/8] common: add ring_get_length() for debugging purposes

Marc-André Lureau marcandre.lureau at redhat.com
Tue May 3 07:37:42 PDT 2011


Please notice it has a "static" modifier, like the rest of the inlined
functions in ring.h, so it won't warn if it isn't used.
---
 common/ring.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/common/ring.h b/common/ring.h
index ff4ef6d..bd030d2 100644
--- a/common/ring.h
+++ b/common/ring.h
@@ -154,6 +154,19 @@ static inline RingItem *ring_prev(Ring *ring, RingItem *pos)
             (var) = ring_prev(ring, var))
 
 
+static inline unsigned int ring_get_length(Ring *ring)
+{
+    RingItem *i;
+    unsigned int ret = 0;
+
+    for (i = ring_get_head(ring);
+         i != NULL;
+         i = ring_next(ring, i))
+        ret++;
+
+    return ret;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.4



More information about the Spice-devel mailing list