From d87135d45a245b35f2f143b7ca970e833af46e8d Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 1 Dec 2007 16:29:22 +0000 Subject: [PATCH] stl_tempbuf.h (__get_temporary_buffer): Fold in get_temporary_buffer. 2007-12-01 Paolo Carlini * include/bits/stl_tempbuf.h (__get_temporary_buffer): Fold in get_temporary_buffer. From-SVN: r130557 --- libstdc++-v3/ChangeLog | 7 +++- libstdc++-v3/include/bits/stl_tempbuf.h | 45 ++++++++++--------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5ac2a97b11b..e5dc1f9b775 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,11 @@ +2007-12-01 Paolo Carlini + + * include/bits/stl_tempbuf.h (__get_temporary_buffer): Fold + in get_temporary_buffer. + 2007-11-29 Andris Pavenis - * src/Makefile.am: Use separate vpath lines for each path. + * src/Makefile.am: Use separate vpath lines for each path. 2007-11-28 Johannes Singler diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index 21adc70c9b3..3a22fab0615 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -68,32 +68,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) - /** - * @if maint - * This is a helper function. The unused second parameter exists to - * permit the real get_temporary_buffer to use template parameter deduction. - * @endif - */ - template - pair<_Tp*, ptrdiff_t> - __get_temporary_buffer(ptrdiff_t __len, _Tp*) - { - const ptrdiff_t __max = - __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); - if (__len > __max) - __len = __max; - - while (__len > 0) - { - _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), - std::nothrow)); - if (__tmp != 0) - return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); - __len /= 2; - } - return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); - } - /** * @brief Allocates a temporary buffer. * @param len The number of objects of type Tp. @@ -112,9 +86,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * Provides the nothrow exception guarantee. */ template - inline pair<_Tp*, ptrdiff_t> + pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) - { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } + { + const ptrdiff_t __max = + __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + if (__len > __max) + __len = __max; + + while (__len > 0) + { + _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), + std::nothrow)); + if (__tmp != 0) + return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len /= 2; + } + return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); + } /** * @brief The companion to get_temporary_buffer().