mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
list: add vlist_clear()
This commit is contained in:
parent
43ce62946b
commit
00176d5e4b
2 changed files with 12 additions and 0 deletions
|
@ -85,6 +85,9 @@ int vlist_destroy(struct vlist *l, dtor_cb_t dtor = nullptr, bool free = false)
|
|||
/** Append an element to the end of the list */
|
||||
void vlist_push(struct vlist *l, void *p);
|
||||
|
||||
/** Clear list */
|
||||
void vlist_clear(struct vlist *l);
|
||||
|
||||
/** Remove all occurences of a list item */
|
||||
void vlist_remove_all(struct vlist *l, void *p);
|
||||
|
||||
|
|
|
@ -96,6 +96,15 @@ void vlist_push(struct vlist *l, void *p)
|
|||
pthread_mutex_unlock(&l->lock);
|
||||
}
|
||||
|
||||
void vlist_clear(struct vlist *l)
|
||||
{
|
||||
pthread_mutex_lock(&l->lock);
|
||||
|
||||
l->length = 0;
|
||||
|
||||
pthread_mutex_unlock(&l->lock);
|
||||
}
|
||||
|
||||
int vlist_remove(struct vlist *l, size_t idx)
|
||||
{
|
||||
pthread_mutex_lock(&l->lock);
|
||||
|
|
Loading…
Add table
Reference in a new issue