summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2016-01-29 12:46:13 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2016-02-01 20:45:21 +0000
commit57ca755d2efbdb7268e8014cb4c50c9ea1c65bfc (patch)
treeff8459ea7129c501526b7c58cbecde50d6d9f857 /src/corelib/tools/qringbuffer.cpp
parent9fb5ff56c35177502791f1e979b2eca1881a70e5 (diff)
QRingBuffer: add append(const char *, qint64) function
This allows to remove a code duplication in several places. Change-Id: I49f56e951682dbd2968923654a12cba5199a2502 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
-rw-r--r--src/corelib/tools/qringbuffer.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index c3cb60a6f0..7e2d909dcd 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -317,6 +317,20 @@ qint64 QRingBuffer::peek(char *data, qint64 maxLength, qint64 pos) const
/*!
\internal
+ Append bytes from data to the end
+*/
+void QRingBuffer::append(const char *data, qint64 size)
+{
+ char *writePointer = reserve(size);
+ if (size == 1)
+ *writePointer = *data;
+ else if (size)
+ ::memcpy(writePointer, data, size);
+}
+
+/*!
+ \internal
+
Append a new buffer to the end
*/
void QRingBuffer::append(const QByteArray &qba)