This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] get_temporary_buffer, redux
- From: "Stephen M. Webb" <stephenw at xandros dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 29 Jan 2004 09:09:37 -0500
- Subject: Re: [v3] get_temporary_buffer, redux
- Organization: Xandros.com
- References: <20040129004345.68a7e699.bkoz@redhat.com>
On Thursday, January 29 2004 01:43, Benjamin Kosnik wrote:
>
> What gives? Here's an updated patch.
I noticed an oops in the patch (mismatched new[]/delete). Here's the correct
patch for config/locale/gnu/c_locale.h.
*** config/locale/gnu/c_locale.h 14 Jul 2003 20:24:18 -0000 1.10
--- config/locale/gnu/c_locale.h 29 Jan 2004 06:40:31 -0000
***************
*** 39,45 ****
#pragma GCC system_header
#include <cstring> // get std::strlen
- #include <cstdlib> // get std::malloc
#include <cstdio> // get std::snprintf or std::sprintf
#include <clocale>
#include <langinfo.h> // For codecvt
--- 39,44 ----
*************** namespace std
*** 76,84 ****
_Tv __v, const __c_locale&, int __prec = -1)
{
char* __old = std::setlocale(LC_ALL, NULL);
! char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1));
! if (__sav)
! std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C");
#endif
--- 75,82 ----
_Tv __v, const __c_locale&, int __prec = -1)
{
char* __old = std::setlocale(LC_ALL, NULL);
! char* __sav = new char[std::strlen(__old) + 1];
! std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C");
#endif
*************** namespace std
*** 99,105 ****
__gnu_cxx::__uselocale(__old);
#else
std::setlocale(LC_ALL, __sav);
! std::free(__sav);
#endif
return __ret;
}
--- 97,103 ----
__gnu_cxx::__uselocale(__old);
#else
std::setlocale(LC_ALL, __sav);
! delete[] __sav;
#endif
return __ret;
}
__
Stephen M. Webb