From fea817da2db72a11acbf25e0a6994d2fca9e9b1c Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Wed, 10 Oct 2018 15:06:45 +0000 Subject: [PATCH] Update: Replaced listensocket_container_new() --- src/connection.c | 2 +- src/listensocket.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/connection.c b/src/connection.c index a71333ce..c533c15e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1703,7 +1703,7 @@ void connection_setup_sockets (ice_config_t *config) allowed_ip = matchfile_new(config->allowfile); } - global.listensockets = listensocket_container_new(); + global.listensockets = refobject_new(listensocket_container_t); listensocket_container_configure(global.listensockets, config); global_unlock(); diff --git a/src/listensocket.c b/src/listensocket.c index 5ed9ad30..2fef714a 100644 --- a/src/listensocket.c +++ b/src/listensocket.c @@ -150,26 +150,25 @@ static void __listensocket_container_free(refobject_t self, void **userdata) thread_mutex_destroy(&container->lock); } -REFOBJECT_DEFINE_TYPE(listensocket_container_t, - REFOBJECT_DEFINE_TYPE_FREE(__listensocket_container_free) - ); - -listensocket_container_t * listensocket_container_new(void) +int __listensocket_container_new(refobject_t self, const refobject_type_t *type, va_list ap) { - listensocket_container_t *self = refobject_new__new(listensocket_container_t, NULL, NULL, NULL); - if (!self) - return NULL; + listensocket_container_t *ret = REFOBJECT_TO_TYPE(self, listensocket_container_t*); - self->sock = NULL; - self->sock_len = 0; - self->sockcount_cb = NULL; - self->sockcount_userdata = NULL; + ret->sock = NULL; + ret->sock_len = 0; + ret->sockcount_cb = NULL; + ret->sockcount_userdata = NULL; - thread_mutex_create(&self->lock); + thread_mutex_create(&ret->lock); - return self; + return 0; } +REFOBJECT_DEFINE_TYPE(listensocket_container_t, + REFOBJECT_DEFINE_TYPE_FREE(__listensocket_container_free), + REFOBJECT_DEFINE_TYPE_NEW(__listensocket_container_new) + ); + static inline void __find_matching_entry(listensocket_container_t *self, const listener_t *listener, listensocket_t ***found, int **ref) { const listener_t *b;