Use more idiomatic code in this codebase
This commit is contained in:
parent
7f2d74df4a
commit
1c6a55f422
@ -4832,7 +4832,7 @@ PUGI__NS_BEGIN
|
||||
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
|
||||
|
||||
// if convert_buffer below throws bad_alloc, we still need to deallocate contents if we own it
|
||||
auto_deleter<void> contents_guard(own ? contents : NULL, xml_memory::deallocate);
|
||||
auto_deleter<void> contents_guard(own ? contents : 0, xml_memory::deallocate);
|
||||
|
||||
// get private buffer
|
||||
char_t* buffer = 0;
|
||||
@ -4842,7 +4842,7 @@ PUGI__NS_BEGIN
|
||||
if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);
|
||||
|
||||
// after this we either deallocate contents (below) or hold on to it via doc->buffer, so we don't need to guard it
|
||||
contents_guard.data = NULL;
|
||||
contents_guard.release();
|
||||
|
||||
// delete original buffer if we performed a conversion
|
||||
if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user