diff --git a/common/include/villas/list.h b/common/include/villas/list.h index f0e0ce39b..e20601060 100644 --- a/common/include/villas/list.h +++ b/common/include/villas/list.h @@ -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); diff --git a/common/lib/list.cpp b/common/lib/list.cpp index 38f890ba4..09fca3b98 100644 --- a/common/lib/list.cpp +++ b/common/lib/list.cpp @@ -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);