[glib/wip/gcleanup: 14/71] gthread-posix: Don't use gslice allocated GRecMutex



commit d7747a1454853424861e919275cee76755811aed
Author: Stef Walter <stefw gnome org>
Date:   Thu Oct 31 23:03:58 2013 +0100

    gthread-posix: Don't use gslice allocated GRecMutex
    
    This leads to problems during cleanup, and seems strange
    to have locks defined in terms of things that need locking.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711753

 glib/gthread-posix.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index c7b68a0..d9ae636 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -271,7 +271,10 @@ g_rec_mutex_impl_new (void)
   pthread_mutexattr_t attr;
   pthread_mutex_t *mutex;
 
-  mutex = g_slice_new (pthread_mutex_t);
+  mutex = malloc (sizeof (pthread_mutex_t));
+  if G_UNLIKELY (mutex == NULL)
+    g_thread_abort (errno, "malloc");
+
   pthread_mutexattr_init (&attr);
   pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
   pthread_mutex_init (mutex, &attr);
@@ -284,7 +287,7 @@ static void
 g_rec_mutex_impl_free (pthread_mutex_t *mutex)
 {
   pthread_mutex_destroy (mutex);
-  g_slice_free (pthread_mutex_t, mutex);
+  free (mutex);
 }
 
 static pthread_mutex_t *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]