forked from boostorg/beast
Some basic_fields operations now give the strong exception guarantee
This commit is contained in:
1 parent
9f094518bc
commit
5d5e58c5b4
3 files changed
+21
-16
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user