Commit f48d9d19 by François Dumont

stl_tempbuf.h (__detail::__return_temporary_buffer): New.

2019-07-18  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer): New.
	(~_Temporary_buffer()): Use latter.
	(_Temporary_buffer(_FIterator, size_type)): Likewise.

From-SVN: r273586
parent 2737c590
2019-07-18 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer): New.
(~_Temporary_buffer()): Use latter.
(_Temporary_buffer(_FIterator, size_type)): Likewise.
2019-07-17 Andreas Schwab <schwab@suse.de> 2019-07-17 Andreas Schwab <schwab@suse.de>
* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Update. * config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Update.
......
...@@ -63,6 +63,21 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -63,6 +63,21 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
template<typename _Tp>
inline void
__return_temporary_buffer(_Tp* __p,
size_t __len __attribute__((__unused__)))
{
#if __cpp_sized_deallocation
::operator delete(__p, __len);
#else
::operator delete(__p);
#endif
}
}
/** /**
* @brief Allocates a temporary buffer. * @brief Allocates a temporary buffer.
* @param __len The number of objects of type Tp. * @param __len The number of objects of type Tp.
...@@ -112,7 +127,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -112,7 +127,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return_temporary_buffer(_Tp* __p) return_temporary_buffer(_Tp* __p)
{ ::operator delete(__p); } { ::operator delete(__p); }
/** /**
* This class is used in two places: stl_algo.h and ext/memory, * This class is used in two places: stl_algo.h and ext/memory,
* where it is wrapped as the temporary_buffer class. See * where it is wrapped as the temporary_buffer class. See
...@@ -165,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -165,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
~_Temporary_buffer() ~_Temporary_buffer()
{ {
std::_Destroy(_M_buffer, _M_buffer + _M_len); std::_Destroy(_M_buffer, _M_buffer + _M_len);
std::return_temporary_buffer(_M_buffer); std::__detail::__return_temporary_buffer(_M_buffer, _M_len);
} }
private: private:
...@@ -185,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -185,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__ucr(_Pointer __first, _Pointer __last, __ucr(_Pointer __first, _Pointer __last,
_ForwardIterator __seed) _ForwardIterator __seed)
{ {
if(__first == __last) if (__first == __last)
return; return;
_Pointer __cur = __first; _Pointer __cur = __first;
...@@ -244,24 +258,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -244,24 +258,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Temporary_buffer(_ForwardIterator __seed, size_type __original_len) _Temporary_buffer(_ForwardIterator __seed, size_type __original_len)
: _M_original_len(__original_len), _M_len(0), _M_buffer(0) : _M_original_len(__original_len), _M_len(0), _M_buffer(0)
{ {
std::pair<pointer, size_type> __p(
std::get_temporary_buffer<value_type>(_M_original_len));
if (__p.first)
{
__try __try
{ {
std::pair<pointer, size_type> __p(std::get_temporary_buffer< std::__uninitialized_construct_buf(__p.first, __p.first + __p.second,
value_type>(_M_original_len)); __seed);
_M_buffer = __p.first; _M_buffer = __p.first;
_M_len = __p.second; _M_len = __p.second;
if (_M_buffer)
std::__uninitialized_construct_buf(_M_buffer, _M_buffer + _M_len,
__seed);
} }
__catch(...) __catch(...)
{ {
std::return_temporary_buffer(_M_buffer); std::__detail::__return_temporary_buffer(__p.first, __p.second);
_M_buffer = 0;
_M_len = 0;
__throw_exception_again; __throw_exception_again;
} }
} }
}
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment