summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2011-05-03 13:53:59 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2011-05-03 16:49:56 +0200
commit2b78b4968a514262d532626d7aee78ad4a481fd2 (patch)
tree76d5e1b3dab1a0cd16dd303210ae97ad9de7a85c /common
parentdc1d4bdb680e6fcfa078fecae5a00966b644b0a9 (diff)
downloadspice-2b78b4968a514262d532626d7aee78ad4a481fd2.tar.gz
spice-2b78b4968a514262d532626d7aee78ad4a481fd2.tar.xz
spice-2b78b4968a514262d532626d7aee78ad4a481fd2.zip
common: add ring_get_length() for debugging purposes
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.
Diffstat (limited to 'common')
-rw-r--r--common/ring.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/ring.h b/common/ring.h
index ff4ef6dd..bd030d25 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