mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 00:28:20 +00:00
[client] ll: add new method ll_peek_tail
This commit is contained in:
parent
67022d664f
commit
271276a0a9
@ -25,7 +25,8 @@ void ll_free (struct ll * list);
|
||||
void ll_push (struct ll * list, void * data);
|
||||
bool ll_shift (struct ll * list, void ** data);
|
||||
bool ll_peek_head(struct ll * list, void ** data);
|
||||
bool ll_peek_tail(struct ll * list, void ** data);
|
||||
unsigned int ll_count (struct ll * list);
|
||||
|
||||
void ll_reset (struct ll * list);
|
||||
bool ll_walk (struct ll * list, void ** data);
|
||||
bool ll_walk (struct ll * list, void ** data);
|
||||
|
@ -92,8 +92,10 @@ bool ll_shift(struct ll * list, void ** data)
|
||||
--list->count;
|
||||
struct ll_item * item = list->head;
|
||||
list->head = item->next;
|
||||
list->pos = NULL;
|
||||
if (list->tail == item)
|
||||
list->tail = NULL;
|
||||
|
||||
list->pos = NULL;
|
||||
LG_UNLOCK(list->lock);
|
||||
|
||||
if (data)
|
||||
@ -118,6 +120,21 @@ bool ll_peek_head(struct ll * list, void ** data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ll_peek_tail(struct ll * list, void ** data)
|
||||
{
|
||||
LG_LOCK(list->lock);
|
||||
if (!list->tail)
|
||||
{
|
||||
LG_UNLOCK(list->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
*data = list->tail->data;
|
||||
LG_UNLOCK(list->lock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int ll_count(struct ll * list)
|
||||
{
|
||||
return list->count;
|
||||
|
Loading…
Reference in New Issue
Block a user