1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

remove unused list functions

This commit is contained in:
Steffen Vogel 2021-06-21 16:07:12 -04:00
parent 0aeb9b471b
commit 30ac7dc3ec
3 changed files with 1 additions and 57 deletions

View file

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

View file

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

View file

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