From c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Dec 2021 22:11:24 -0500 Subject: Use static initialization for lists and mutexes. This eliminates some run-time initialization, moving it to compile time. Additional follow up work will expand on this to simplify initialization and reduce the need for certain locks. --- src/sp/transport.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/sp') diff --git a/src/sp/transport.c b/src/sp/transport.c index ed27ebeb..9f4c6522 100644 --- a/src/sp/transport.c +++ b/src/sp/transport.c @@ -14,8 +14,9 @@ #include #include -static nni_list sp_tran_list; -static nni_rwlock sp_tran_lk; +static nni_list sp_tran_list = + NNI_LIST_INITIALIZER(sp_tran_list, nni_sp_tran, tran_link); +static nni_rwlock sp_tran_lk = NNI_RWLOCK_INITIALIZER; void nni_sp_tran_register(nni_sp_tran *tran) @@ -73,9 +74,6 @@ extern void nni_sp_zt_register(void); void nni_sp_tran_sys_init(void) { - NNI_LIST_INIT(&sp_tran_list, nni_sp_tran, tran_link); - nni_rwlock_init(&sp_tran_lk); - #ifdef NNG_TRANSPORT_INPROC nni_sp_inproc_register(); #endif @@ -110,5 +108,4 @@ nni_sp_tran_sys_fini(void) nni_list_remove(&sp_tran_list, t); t->tran_fini(); } - nni_rwlock_fini(&sp_tran_lk); } -- cgit v1.2.3-70-g09d2