aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-09-22 11:31:33 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-09-22 11:31:33 +0200
commit92ac8df0ec0b81d3655229f488201634e99088f8 (patch)
treeeacea83f51cacc05897b95f2a4dfb6a587f15fd4 /src/libutil/serialise.cc
parente7f1109f06444d5facbfe9839e33a6183e2e4780 (diff)
parentca30abb3fb36440e5a13161c39647189036fc18f (diff)
Merge branch 'add-ca-to-store' of https://github.com/hercules-ci/nix
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r--src/libutil/serialise.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index 00c945113..a469a1e73 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -93,7 +93,7 @@ void Source::operator () (unsigned char * data, size_t len)
}
-std::string Source::drain()
+void Source::drainInto(Sink & sink)
{
std::string s;
std::vector<unsigned char> buf(8192);
@@ -101,12 +101,19 @@ std::string Source::drain()
size_t n;
try {
n = read(buf.data(), buf.size());
- s.append((char *) buf.data(), n);
+ sink(buf.data(), n);
} catch (EndOfFile &) {
break;
}
}
- return s;
+}
+
+
+std::string Source::drain()
+{
+ StringSink s;
+ drainInto(s);
+ return *s.s;
}