diff options
author | Owen Taylor <otaylor@src.gnome.org> | 1998-12-15 05:28:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-12-15 05:28:02 +0000 |
commit | 931ea952650b013b834041b91b0c37a748ffd449 (patch) | |
tree | 0c97c450b0e07953d836f1603c6fcb0357a58149 /gstrfuncs.c | |
parent | c8ba100dab8949c49097f11004c09ef36ea5136f (diff) | |
download | glib-931ea952650b013b834041b91b0c37a748ffd449.tar.gz |
This commit merges the glib-threads branch into the main
branch. See the ChangeLog for details of the changes.
In brief overview:
- The set of threading functions can be set
- A default implementation is provided in -lgthread
- All static data structures are locked using these
functions if g_thread_init() is called.
Diffstat (limited to 'gstrfuncs.c')
-rw-r--r-- | gstrfuncs.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/gstrfuncs.c b/gstrfuncs.c index ad28978ee..e154c56dc 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* + * MT safe + */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -208,7 +212,8 @@ g_strtod (const gchar *nptr, gchar* g_strerror (gint errnum) { - static char msg[64]; + static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT; + char *msg; #ifdef HAVE_STRERROR return strerror (errnum); @@ -634,7 +639,14 @@ g_strerror (gint errnum) if ((errnum > 0) && (errnum <= sys_nerr)) return sys_errlist [errnum]; #endif /* NO_SYS_ERRLIST */ - + + msg = g_static_private_get (&msg_private); + if( !msg ) + { + msg = g_new( gchar, 64 ); + g_static_private_set (&msg_private, msg, g_free); + } + sprintf (msg, "unknown error (%d)", errnum); return msg; } @@ -642,7 +654,8 @@ g_strerror (gint errnum) gchar* g_strsignal (gint signum) { - static char msg[64]; + static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT; + char *msg; #ifdef HAVE_STRSIGNAL extern char *strsignal (int sig); @@ -748,6 +761,13 @@ g_strsignal (gint signum) extern char *sys_siglist[]; return sys_siglist [signum]; #endif /* NO_SYS_SIGLIST */ + + msg = g_static_private_get (&msg_private); + if( !msg ) + { + msg = g_new( gchar, 64 ); + g_static_private_set (&msg_private, msg, g_free); + } sprintf (msg, "unknown signal (%d)", signum); return msg; |