[glib/wip/mutexes: 7/12] Port g_cond_new to use GSlice



commit f73b9dab737581c12c2d6feb68d8056c7489afbc
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Sep 17 18:07:39 2011 -0400

    Port g_cond_new to use GSlice
    
    Now that nothing inside of GLib is using g_cond_new(), we can implement
    it using GSlice.  Since the implementations for POSIX and Windows are
    now the same, move it to gthread.c.

 glib/gthread-posix.c |   23 -----------------------
 glib/gthread-win32.c |   22 ----------------------
 glib/gthread.c       |   18 ++++++++++++++++++
 3 files changed, 18 insertions(+), 45 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 53ee362..02b944f 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -223,29 +223,6 @@ g_cond_timedwait (GCond  *cond,
   return FALSE;
 }
 
-/* {{{1 new/free API */
-
-GCond *
-g_cond_new (void)
-{
-  GCond *cond;
-
-  /* malloc() is temporary until all libglib users are ported away */
-  cond = malloc (sizeof (GCond));
-  if G_UNLIKELY (cond == NULL)
-    g_thread_abort (errno, "malloc");
-  g_cond_init (cond);
-
-  return cond;
-}
-
-void
-g_cond_free (GCond *cond)
-{
-  g_cond_clear (cond);
-  free (cond);
-}
-
 /* {{{1 GPrivate */
 
 #include "glib.h"
diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
index 91510c5..d63864c 100644
--- a/glib/gthread-win32.c
+++ b/glib/gthread-win32.c
@@ -252,28 +252,6 @@ g_cond_timed_wait (GCond    *cond,
     }
 }
 
-/* {{{1 new/free API */
-GCond *
-g_cond_new (void)
-{
-  GCond *cond;
-
-  /* malloc() is temporary until all libglib users are ported away */
-  cond = malloc (sizeof (GCond));
-  if G_UNLIKELY (cond == NULL)
-    g_thread_abort (errno, "malloc");
-  g_cond_init (cond);
-
-  return cond;
-}
-
-void
-g_cond_free (GCond *cond)
-{
-  g_cond_clear (cond);
-  free (cond);
-}
-
 /* {{{1 GPrivate */
 
 #include "glib.h"
diff --git a/glib/gthread.c b/glib/gthread.c
index 75f2af6..5c7522b 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -2590,3 +2590,21 @@ g_mutex_free (GMutex *mutex)
   g_mutex_clear (mutex);
   g_slice_free (GMutex, mutex);
 }
+
+GCond *
+g_cond_new (void)
+{
+  GCond *cond;
+
+  cond = g_slice_new (GCond);
+  g_cond_init (cond);
+
+  return cond;
+}
+
+void
+g_cond_free (GCond *cond)
+{
+  g_cond_clear (cond);
+  g_slice_free (GCond, cond);
+}



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