vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Thu Aug 18 17:18:22 2011 +0300| [73b30f82b1b1f65826b356c36bfdcaa51b3e14ea] | committer: Rémi Denis-Courmont
Create the C/POSIX locale on need-basis in message subsystem The overhead is negligible, and this avoids depending on the message bank. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73b30f82b1b1f65826b356c36bfdcaa51b3e14ea --- src/misc/messages.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/misc/messages.c b/src/misc/messages.c index f1d7078..e397c71 100644 --- a/src/misc/messages.c +++ b/src/misc/messages.c @@ -88,7 +88,6 @@ struct msg_bank_t int i_sub; msg_subscription_t **pp_sub; - locale_t locale; /**< C locale for error messages */ vlc_dictionary_t enabled_objects; ///< Enabled objects bool all_objects_enabled; ///< Should we print all objects? }; @@ -108,8 +107,6 @@ msg_bank_t *msg_Create (void) bank->i_sub = 0; bank->pp_sub = NULL; - /* C locale to get error messages in English in the logs */ - bank->locale = newlocale (LC_MESSAGES_MASK, "C", (locale_t)0); return bank; } @@ -160,9 +157,6 @@ void msg_Destroy (msg_bank_t *bank) if (unlikely(bank->i_sub != 0)) fputs ("stale interface subscribers (LibVLC might crash)\n", stderr); - if (bank->locale != (locale_t)0) - freelocale (bank->locale); - vlc_dictionary_clear (&bank->enabled_objects, NULL, NULL); vlc_rwlock_destroy (&bank->lock); @@ -270,7 +264,10 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, return; msg_bank_t *bank = libvlc_bank (p_this->p_libvlc); - locale_t locale = uselocale (bank->locale); + + /* C locale to get error messages in English in the logs */ + locale_t c = newlocale (LC_MESSAGES_MASK, "C", (locale_t)0); + locale_t locale = uselocale (c); #ifndef __GLIBC__ /* Expand %m to strerror(errno) - only once */ @@ -334,7 +331,10 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, psz_str = NULL; va_end( args ); - if( psz_str == NULL ) + uselocale (locale); + freelocale (c); + + if (unlikely(psz_str == NULL)) { int canc = vlc_savecancel (); /* Do not print half of a message... */ #ifdef __GLIBC__ @@ -357,10 +357,8 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, va_end( args ); fputs( "\n", stderr ); vlc_restorecancel (canc); - uselocale (locale); return; } - uselocale (locale); /* Fill message information fields */ msg_item_t msg; _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
