Some basic_fields operations now give the strong exception guarantee

This commit is contained in:
Vinnie Falco
2018-02-26 14:18:55 -08:00
parent 9f094518bc
commit 5d5e58c5b4
3 changed files with 21 additions and 16 deletions

View File

@ -2,6 +2,7 @@ Version 159:
* Fix typo in release notes
* Safe treatment of zero-length string arguments in basic_fields
* Some basic_fields operations now give the strong exception guarantee
--------------------------------------------------------------------------------

View File

@ -77,6 +77,8 @@ to update to the latest Boost release.
* ([issue 1026]) Advanced servers support clean shutdown via SIGINT or SIGTERM
* Some basic_fields operations now give the strong exception guarantee
[*Fixes]
* Fix "warning: const type qualifier on return type has no effect"

View File

@ -1219,18 +1219,19 @@ realloc_string(string_view& dest, string_view s)
auto a = typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<
char>(this->member());
if(! dest.empty())
{
a.deallocate(const_cast<char*>(
dest.data()), dest.size());
dest = {};
}
char* p = nullptr;
if(! s.empty())
{
auto const p = a.allocate(s.size());
p = a.allocate(s.size());
s.copy(p, s.size());
dest = {p, s.size()};
}
if(! dest.empty())
a.deallocate(const_cast<char*>(
dest.data()), dest.size());
if(p)
dest = {p, s.size()};
else
dest = {};
}
template<class Allocator>
@ -1247,19 +1248,20 @@ realloc_target(
auto a = typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<
char>(this->member());
if(! dest.empty())
{
a.deallocate(const_cast<char*>(
dest.data()), dest.size());
dest = {};
}
char* p = nullptr;
if(! s.empty())
{
auto const p = a.allocate(1 + s.size());
p = a.allocate(1 + s.size());
p[0] = ' ';
s.copy(p + 1, s.size());
dest = {p, 1 + s.size()};
}
if(! dest.empty())
a.deallocate(const_cast<char*>(
dest.data()), dest.size());
if(p)
dest = {p, 1 + s.size()};
else
dest = {};
}
template<class Allocator>