aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/handle.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-16 17:37:09 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-16 21:08:10 +0300
commit38a76bafce303d211043fd118119c9431cdbe932 (patch)
treefa03ed49dff2ad8b50dae8eff48f12291b0c320e /src/handle.cpp
parentVS 2013 workarounds (diff)
downloadwinapi-common-38a76bafce303d211043fd118119c9431cdbe932.tar.gz
winapi-common-38a76bafce303d211043fd118119c9431cdbe932.zip
add a separate Buffer class
Diffstat (limited to 'src/handle.cpp')
-rw-r--r--src/handle.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/handle.cpp b/src/handle.cpp
index a6ab3a5..1147cf6 100644
--- a/src/handle.cpp
+++ b/src/handle.cpp
@@ -3,6 +3,7 @@
// For details, see https://github.com/egor-tensin/winapi-common.
// Distributed under the MIT License.
+#include <winapi/buffer.hpp>
#include <winapi/error.hpp>
#include <winapi/handle.hpp>
#include <winapi/workarounds.hpp>
@@ -15,6 +16,7 @@
#include <cstddef>
#include <sstream>
#include <stdexcept>
+#include <utility>
namespace winapi {
namespace {
@@ -100,15 +102,13 @@ bool Handle::read_chunk(Buffer& buffer) const {
}
}
-Handle::Buffer Handle::read() const {
+Buffer Handle::read() const {
Buffer buffer;
- Buffer chunk;
while (true) {
+ Buffer chunk;
const auto next = read_chunk(chunk);
-
- buffer.reserve(buffer.size() + chunk.size());
- buffer.insert(buffer.cend(), chunk.cbegin(), chunk.cend());
+ buffer.add(chunk);
if (!next) {
break;