diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-11-10 17:13:27 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-11-27 10:59:25 +0100 |
commit | ded49076c84048003e4c94da2d53ed93b21740af (patch) | |
tree | dd15fd651876450e878dd512da5e3762d5998606 /common | |
parent | fbad8a9adb7d67388914e857181ce2ed55547721 (diff) | |
download | tigervnc-ded49076c84048003e4c94da2d53ed93b21740af.tar.gz tigervnc-ded49076c84048003e4c94da2d53ed93b21740af.zip |
Add efficient method to copy data between two streams
Diffstat (limited to 'common')
-rw-r--r-- | common/rdr/OutStream.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h index 94d57dd3..a749a208 100644 --- a/common/rdr/OutStream.h +++ b/common/rdr/OutStream.h @@ -25,6 +25,7 @@ #define __RDR_OUTSTREAM_H__ #include <rdr/types.h> +#include <rdr/InStream.h> #include <string.h> // for memcpy namespace rdr { @@ -100,6 +101,17 @@ namespace rdr { } } + // copyBytes() efficiently transfers data between streams + + void copyBytes(InStream* is, int length) { + while (length > 0) { + int n = check(1, length); + is->readBytes(ptr, n); + ptr += n; + length -= n; + } + } + // writeOpaqueN() writes a quantity without byte-swapping. inline void writeOpaque8( U8 u) { writeU8(u); } |