aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-07-13 17:30:42 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-07-13 17:30:42 +0200
commit0a9da00a10fa27a3e3b98439cb0a7d5e79135b58 (patch)
tree34057b575b3a5e5d6c556bff73e6dc5960229aee /src/libutil/serialise.hh
parentfc84c358d9e55e9ba1d939d8974f6deef629848e (diff)
NarAccessor: Run in constant memory
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r--src/libutil/serialise.hh10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index bd651fb7d..84a4eb001 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -179,17 +179,17 @@ struct TeeSink : Sink
};
-/* Adapter class of a Source that saves all data read to `s'. */
+/* Adapter class of a Source that saves all data read to a sink. */
struct TeeSource : Source
{
Source & orig;
- ref<std::string> data;
- TeeSource(Source & orig)
- : orig(orig), data(make_ref<std::string>()) { }
+ Sink & sink;
+ TeeSource(Source & orig, Sink & sink)
+ : orig(orig), sink(sink) { }
size_t read(unsigned char * data, size_t len)
{
size_t n = orig.read(data, len);
- this->data->append((const char *) data, n);
+ sink(data, len);
return n;
}
};