mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed so that the newest element is returned with ringbuf_next aswell
This commit is contained in:
parent
e138d5c76a
commit
be33e56abc
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue