mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-14 03:20:22 +00:00
[client] ll: add new method ll_peek_tail
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user