1
0
Fork 0
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:
Manuel Pitz 2020-10-21 20:59:23 +02:00 committed by Steffen Vogel
parent 43ce62946b
commit 00176d5e4b
2 changed files with 12 additions and 0 deletions

View file

@ -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);

View file

@ -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);