diff options
author | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
commit | b34738ed08c2227300d554b139e2495ca5da97d6 (patch) | |
tree | 62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libstrongswan/threading/thread_value.c | |
parent | 0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff) | |
download | vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip |
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libstrongswan/threading/thread_value.c')
-rw-r--r-- | src/libstrongswan/threading/thread_value.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/libstrongswan/threading/thread_value.c b/src/libstrongswan/threading/thread_value.c index 8f2a8846c..3fa70acb2 100644 --- a/src/libstrongswan/threading/thread_value.c +++ b/src/libstrongswan/threading/thread_value.c @@ -35,27 +35,20 @@ struct private_thread_value_t { }; - -/** - * Implementation of thread_value_t.set. - */ -static void set(private_thread_value_t *this, void *val) +METHOD(thread_value_t, set, void, + private_thread_value_t *this, void *val) { pthread_setspecific(this->key, val); } -/** - * Implementation of thread_value_t.get. - */ -static void *get(private_thread_value_t *this) +METHOD(thread_value_t, get, void*, + private_thread_value_t *this) { return pthread_getspecific(this->key); } -/** - * Implementation of thread_value_t.destroy. - */ -static void destroy(private_thread_value_t *this) +METHOD(thread_value_t, destroy, void, + private_thread_value_t *this) { pthread_key_delete(this->key); free(this); @@ -67,10 +60,15 @@ static void destroy(private_thread_value_t *this) */ thread_value_t *thread_value_create(thread_cleanup_t destructor) { - private_thread_value_t *this = malloc_thing(private_thread_value_t); - this->public.set = (void(*)(thread_value_t*,void*))set; - this->public.get = (void*(*)(thread_value_t*))get; - this->public.destroy = (void(*)(thread_value_t*))destroy; + private_thread_value_t *this; + + INIT(this, + .public = { + .set = _set, + .get = _get, + .destroy = _destroy, + }, + ); pthread_key_create(&this->key, destructor); return &this->public; |