[v3] get_temporary_buffer, redux
Stephen M. Webb
stephenw@xandros.com
Thu Jan 29 14:12:00 GMT 2004
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
More information about the Libstdc++
mailing list