diff --git a/common/include/villas/list.h b/common/include/villas/list.h index 851d31e39..f0e0ce39b 100644 --- a/common/include/villas/list.h +++ b/common/include/villas/list.h @@ -153,4 +153,6 @@ ssize_t vlist_lookup_index(struct vlist *l, const std::string &name) auto *f = vlist_lookup_name(l, name); return f ? vlist_index(l, f) : -1; -} \ No newline at end of file +} + +int vlist_init_and_push(struct vlist *l, void *p); \ No newline at end of file diff --git a/common/lib/list.cpp b/common/lib/list.cpp index 8050add7b..38f890ba4 100644 --- a/common/lib/list.cpp +++ b/common/lib/list.cpp @@ -287,3 +287,18 @@ void vlist_filter(struct vlist *l, dtor_cb_t cb) pthread_mutex_unlock(&l->lock); } + +int vlist_init_and_push(struct vlist *l, void *p) +{ + int ret; + + if (l->state == State::DESTROYED) { + ret = vlist_init(l); + if (ret) + return ret; + } + + vlist_push(l, p); + + return 0; +} \ No newline at end of file