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.
This commit is contained in:
Marc-André Lureau 2011-05-03 13:53:59 +02:00
parent dc1d4bdb68
commit 2b78b4968a

View File

@ -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