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

list: do not check state during intialization

parent fc20afe0
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
/** Static list initialization */ /** Static list initialization */
#define LIST_INIT_STATIC(l) \ #define LIST_INIT_STATIC(l) \
__attribute__((constructor(105))) static void UNIQUE(__ctor)() {\ __attribute__((constructor(105))) static void UNIQUE(__ctor)() {\
if ((l)->state == State::DESTROYED) \ vlist_init(l); \
vlist_init(l); \
} \ } \
__attribute__((destructor(105))) static void UNIQUE(__dtor)() { \ __attribute__((destructor(105))) static void UNIQUE(__dtor)() { \
vlist_destroy(l, nullptr, false); \ vlist_destroy(l, nullptr, false); \
......
...@@ -55,8 +55,6 @@ static int cmp_sort(const void *a, const void *b, void *thunk) { ...@@ -55,8 +55,6 @@ static int cmp_sort(const void *a, const void *b, void *thunk) {
int vlist_init(struct vlist *l) int vlist_init(struct vlist *l)
{ {
assert(l->state == State::DESTROYED);
pthread_mutex_init(&l->lock, nullptr); pthread_mutex_init(&l->lock, nullptr);
l->length = 0; l->length = 0;
......
...@@ -42,7 +42,6 @@ TestSuite(list, .description = "List datastructure"); ...@@ -42,7 +42,6 @@ TestSuite(list, .description = "List datastructure");
Test(list, vlist_lookup) Test(list, vlist_lookup)
{ {
struct vlist l; struct vlist l;
l.state = State::DESTROYED;
vlist_init(&l); vlist_init(&l);
...@@ -67,7 +66,6 @@ Test(list, vlist_lookup) ...@@ -67,7 +66,6 @@ Test(list, vlist_lookup)
Test(list, vlist_search) Test(list, vlist_search)
{ {
struct vlist l; struct vlist l;
l.state = State::DESTROYED;
vlist_init(&l); vlist_init(&l);
...@@ -108,7 +106,6 @@ static int dtor(void *ptr) ...@@ -108,7 +106,6 @@ static int dtor(void *ptr)
Test(list, destructor) Test(list, destructor)
{ {
struct vlist l; struct vlist l;
l.state = State::DESTROYED;
struct content elm; struct content elm;
elm.destroyed = 0; elm.destroyed = 0;
...@@ -128,7 +125,6 @@ Test(list, basics) ...@@ -128,7 +125,6 @@ Test(list, basics)
uintptr_t i; uintptr_t i;
int ret; int ret;
struct vlist l; struct vlist l;
l.state = State::DESTROYED;
vlist_init(&l); vlist_init(&l);
......
Supports Markdown
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