Commit 1c1f4f7a authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

remove unused list functions

parent 6fb72537
......@@ -123,18 +123,6 @@ void vlist_extend(struct vlist *l, size_t len, void *val);
/** Remove all elements for which the callback returns a non-zero return code. */
void vlist_filter(struct vlist *l, dtor_cb_t cb);
/** Lookup an element from the list based on an UUID */
template<typename T>
T * vlist_lookup_uuid(struct vlist *l, uuid_t uuid)
{
return (T *) vlist_search(l, [](const void *a, const void *b) -> int {
auto *n = reinterpret_cast<const T *>(a);
uuid_t u; memcpy(u, b, sizeof(uuid_t));
return uuid_compare(n->uuid, u);
}, uuid);
}
/** Lookup an element from the list based on a name */
template<typename T>
T * vlist_lookup_name(struct vlist *l, const std::string &name)
......@@ -155,5 +143,3 @@ ssize_t vlist_lookup_index(struct vlist *l, const std::string &name)
return f ? vlist_index(l, f) : -1;
}
int vlist_init_and_push(struct vlist *l, void *p);
......@@ -94,7 +94,7 @@ void vlist_clear(struct vlist *l)
pthread_mutex_lock(&l->lock);
l->length = 0;
pthread_mutex_unlock(&l->lock);
}
......@@ -291,18 +291,3 @@ 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;
}
......@@ -40,33 +40,6 @@ struct data {
// cppcheck-suppress unknownMacro
TestSuite(list, .description = "List datastructure");
Test(list, vlist_lookup_name)
{
int ret;
struct vlist l;
ret = vlist_init(&l);
cr_assert_eq(ret, 0);
for (unsigned i = 0; i < ARRAY_LEN(nouns); i++) {
struct data *d = new struct data;
if (!d)
throw MemoryAllocationError();
d->name = nouns[i];
d->data = i;
vlist_push(&l, d);
}
struct data *found = vlist_lookup_name<struct data>(&l, "woman");
cr_assert_eq(found->data, 13);
ret = vlist_destroy(&l, nullptr, true);
cr_assert_eq(ret, 0);
}
Test(list, vlist_search)
{
int ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment