This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [PATCH] codecvt<wchar_t, char, mbstate_t> support for UTF-8
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Benjamin Kosnik" <bkoz at redhat dot com>
- Cc: <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 27 Jan 2003 19:23:44 -0000
- Subject: RE: [PATCH] codecvt<wchar_t, char, mbstate_t> support for UTF-8
Benjamin Kosnik wrote:
> >You are of course right that MB_CUR_MAX is not thread-safe in general
> >(since it depends on the global locale set by setlocale).
> This however
> >seems to be a general problem with the generic locale implementation
> >(including codecvt<wchar_t, char, mbstate_t>::do_in and do_out).
>
> This is also correct.
Well, actually the use of MB_CUR_MAX in do_encoding is not thread-unsafe
per se, it is simply unsafe :-) One usage for MB_CUR_MAX is to calculate
buffer sizes for do_out, if setlocale is called between do_encoding and
do_out, the buffer size may be wrong. It doesn't matter if setlocale is
called from the same thread or from a different one.
Regards,
Petur