[vlc-devel] commit: Don't leak message contexts at end of threads ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 17 21:26:52 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jan 17 22:26:37 2009 +0200| [fe657df078d6ce2f7f5489cf3be76d1e34b8e705] | committer: Rémi Denis-Courmont 

Don't leak message contexts at end of threads

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fe657df078d6ce2f7f5489cf3be76d1e34b8e705
---

 src/misc/messages.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/misc/messages.c b/src/misc/messages.c
index a1b9530..a3462ba 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -61,6 +61,13 @@ typedef struct
     char * psz_message;
 } msg_context_t;
 
+static void cleanup_msg_context (void *data)
+{
+    msg_context_t *ctx = data;
+    free (ctx->psz_message);
+    free (ctx);
+}
+
 static vlc_threadvar_t msg_context;
 static uintptr_t banks = 0;
 
@@ -117,7 +124,7 @@ void msg_Create (libvlc_int_t *p_libvlc)
 
     vlc_mutex_lock( &msg_stack_lock );
     if( banks++ == 0 )
-        vlc_threadvar_create( &msg_context, NULL );
+        vlc_threadvar_create( &msg_context, cleanup_msg_context );
     vlc_mutex_unlock( &msg_stack_lock );
 }
 




More information about the vlc-devel mailing list