From: Søren Sandmann Pedersen Date: Wed, 30 Jun 2010 06:31:10 +0000 (-0400) Subject: Fix memory leak in the pthreads thread local storage code X-Git-Tag: 1.0_branch~560 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c935473d8a193b3510f8605a6658ea6ac998fd1;p=profile%2Fivi%2Fpixman.git Fix memory leak in the pthreads thread local storage code When a thread exits, we leak whatever is stored in thread local variables, so install a destructor to free it. --- diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h index f0f9d91..2b15cc3 100644 --- a/pixman/pixman-compiler.h +++ b/pixman/pixman-compiler.h @@ -72,9 +72,9 @@ /* TLS */ #if defined(PIXMAN_NO_TLS) -# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ static type name -# define PIXMAN_GET_THREAD_LOCAL(name) \ +# define PIXMAN_GET_THREAD_LOCAL(name) \ (&name) #elif defined(TOOLCHAIN_SUPPORTS__THREAD) @@ -165,9 +165,16 @@ extern __stdcall int ReleaseMutex (void *); static pthread_key_t tls_ ## name ## _key; \ \ static void \ + tls_ ## name ## _destroy_value (void *value) \ + { \ + free (value); \ + } \ + \ + static void \ tls_ ## name ## _make_key (void) \ { \ - pthread_key_create (&tls_ ## name ## _key, NULL); \ + pthread_key_create (&tls_ ## name ## _key, \ + tls_ ## name ## _destroy_value); \ } \ \ static type * \