fixed so that the newest element is returned with ringbuf_next aswell

This commit is contained in:
Magnus Auvinen 2008-02-03 23:57:03 +00:00
parent e138d5c76a
commit be33e56abc

View file

@ -184,6 +184,11 @@ void *ringbuf_prev(RINGBUFFER *rb, void *current)
void *ringbuf_next(RINGBUFFER *rb, void *current)
{
RBITEM *item = ((RBITEM *)current) - 1;
/* we have gone around */
if(item == rb->last_alloc)
return 0;
while(1)
{
/* back up one step */
@ -191,10 +196,6 @@ void *ringbuf_next(RINGBUFFER *rb, void *current)
if(!item)
item = rb->first;
/* we have gone around */
if(item == rb->last_alloc)
return 0;
if(!(item->flags&RBFLAG_FREE))
return item+1;
}