locale_facets.tcc (time_put::do_put): Consider sizeof(char_type) in allocating the buffer.

2002-03-10  Paolo Carlini  <pcarlini@unitus.it>

        * include/bits/locale_facets.tcc (time_put::do_put):
	Consider sizeof(char_type) in allocating the buffer.

	* include/bits/locale_facets.tcc (collate::do_tranform):
	Remove redundant variable.

From-SVN: r50553
This commit is contained in:
Paolo Carlini 2002-03-10 23:51:31 +00:00
parent 561c9153eb
commit c15892e05e
2 changed files with 19 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2002-03-10 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (time_put::do_put):
Consider sizeof(char_type) in allocating the buffer.
* include/bits/locale_facets.tcc (collate::do_tranform):
Remove redundant variable.
2002-03-10 Ulrich Drepper <drepper@redhat.com>
Paolo Carlini <pcarlini@unitus.it>

View File

@ -1795,7 +1795,8 @@ namespace std
// NB: This size is arbitrary. Should this be a data member,
// initialized at construction?
const size_t __maxlen = 64;
char_type* __res = static_cast<char_type*>(__builtin_alloca(__maxlen));
char_type* __res =
static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
// NB: In IEE 1003.1-200x, and perhaps other locale models, it
// is possible that the format character will be longer than one
@ -1856,14 +1857,15 @@ namespace std
{
size_t __len = (__hi - __lo) * 2;
// First try a buffer perhaps big enough.
_CharT* __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
_CharT* __c =
static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
size_t __res = _M_transform_helper(__c, __lo, __len);
// If the buffer was not large enough, try again with the correct size.
if (__res >= __len)
{
_CharT* __c2 =
static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));
size_t __res2 = _M_transform_helper(__c2, __lo, __res + 1);
_M_transform_helper(__c2, __lo, __res + 1);
return string_type(__c2);
}
return string_type(__c);