From e4b3987cc6e2cc1a28bbaf566f0fb6625e25f3ee Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 22 Nov 2018 15:00:12 +0100 Subject: stdbuf: Track buffer size --- include/object/stdbuf.h | 7 ++++++- include/object/xdrstream.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'include/object') diff --git a/include/object/stdbuf.h b/include/object/stdbuf.h index db30621..271c3ea 100644 --- a/include/object/stdbuf.h +++ b/include/object/stdbuf.h @@ -8,12 +8,17 @@ class BufferOutput : public T { private: BufferOutput(const BufferOutput ©); char *buffer; + uint16_t length; public: - BufferOutput(char *target) { buffer = target; } + BufferOutput(char *target) : buffer(target), length(0) {} virtual void put(char c) { *buffer = c; buffer++; + length++; + } + inline uint16_t size() { + return length; } }; diff --git a/include/object/xdrstream.h b/include/object/xdrstream.h index 55bef5b..e8d4ddc 100644 --- a/include/object/xdrstream.h +++ b/include/object/xdrstream.h @@ -6,7 +6,7 @@ class XDRStream { private: XDRStream(const XDRStream& copy); - uint32_t next_array_len; + uint16_t next_array_len; bool is_fixed_length; public: -- cgit v1.2.3