mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 23:46:15 +01:00
Port g_mutex_new to use GSlice
Now that nothing inside of GLib is using g_mutex_new, we can implement it using GSlice. Since the implementations for POSIX and Windows are now the same, move it to gthread.c.
This commit is contained in:
parent
cf26a6fc32
commit
22b3e26034
@ -225,27 +225,6 @@ g_cond_timedwait (GCond *cond,
|
||||
|
||||
/* {{{1 new/free API */
|
||||
|
||||
GMutex *
|
||||
g_mutex_new (void)
|
||||
{
|
||||
GMutex *mutex;
|
||||
|
||||
/* malloc() is temporary until all libglib users are ported away */
|
||||
mutex = malloc (sizeof (GMutex));
|
||||
if G_UNLIKELY (mutex == NULL)
|
||||
g_thread_abort (errno, "malloc");
|
||||
g_mutex_init (mutex);
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void
|
||||
g_mutex_free (GMutex *mutex)
|
||||
{
|
||||
g_mutex_clear (mutex);
|
||||
free (mutex);
|
||||
}
|
||||
|
||||
GCond *
|
||||
g_cond_new (void)
|
||||
{
|
||||
|
@ -253,27 +253,6 @@ g_cond_timed_wait (GCond *cond,
|
||||
}
|
||||
|
||||
/* {{{1 new/free API */
|
||||
GMutex *
|
||||
g_mutex_new (void)
|
||||
{
|
||||
GMutex *mutex;
|
||||
|
||||
/* malloc() is temporary until all libglib users are ported away */
|
||||
mutex = malloc (sizeof (GMutex));
|
||||
if G_UNLIKELY (mutex == NULL)
|
||||
g_thread_abort (errno, "malloc");
|
||||
g_mutex_init (mutex);
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void
|
||||
g_mutex_free (GMutex *mutex)
|
||||
{
|
||||
g_mutex_clear (mutex);
|
||||
free (mutex);
|
||||
}
|
||||
|
||||
GCond *
|
||||
g_cond_new (void)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include "gthread.h"
|
||||
#include "gthreadprivate.h"
|
||||
#include "gslice.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
@ -2575,3 +2576,21 @@ g_thread_get_initialized ()
|
||||
{
|
||||
return g_thread_supported ();
|
||||
}
|
||||
|
||||
GMutex *
|
||||
g_mutex_new (void)
|
||||
{
|
||||
GMutex *mutex;
|
||||
|
||||
mutex = g_slice_new (GMutex);
|
||||
g_mutex_init (mutex);
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void
|
||||
g_mutex_free (GMutex *mutex)
|
||||
{
|
||||
g_mutex_clear (mutex);
|
||||
g_slice_free (GMutex, mutex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user