diff options
author | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-10-12 21:00:17 +0200 |
---|---|---|
committer | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-10-13 16:58:17 +0200 |
commit | a0032d285f9148a9ae7f46e2d9c0e24a6fa84d0d (patch) | |
tree | af04daeab9a163d4fed7b498be7614bef5004569 | |
parent | 5afb5326cb0392ad9537e1086b4699f6f6f09bf6 (diff) | |
download | qtwebsockets-a0032d285f9148a9ae7f46e2d9c0e24a6fa84d0d.tar.gz |
Call other mask function instead of implementing it twice
Change-Id: Ib196422ed7de2da420010e89347c98a02affef9a
Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com>
-rw-r--r-- | src/websockets/qwebsocketprotocol.cpp | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/src/websockets/qwebsocketprotocol.cpp b/src/websockets/qwebsocketprotocol.cpp index e1f3afb..9acc8ed 100644 --- a/src/websockets/qwebsocketprotocol.cpp +++ b/src/websockets/qwebsocketprotocol.cpp @@ -134,24 +134,7 @@ Version versionFromString(const QString &versionString) */ void mask(QByteArray *payload, quint32 maskingKey) { - quint32 *payloadData = reinterpret_cast<quint32 *>(payload->data()); - const quint32 numIterations = static_cast<quint32>(payload->size()) / sizeof(quint32); - const quint32 remainder = static_cast<quint32>(payload->size()) % sizeof(quint32); - quint32 i; - for (i = 0; i < numIterations; ++i) - { - *(payloadData + i) ^= maskingKey; - } - if (remainder) - { - const quint32 offset = i * static_cast<quint32>(sizeof(quint32)); - char *payloadBytes = payload->data(); - const uchar *mask = reinterpret_cast<uchar *>(&maskingKey); - for (quint32 i = 0; i < remainder; ++i) - { - *(payloadBytes + offset + i) ^= static_cast<char>(mask[(i + offset) % 4]); - } - } + mask(payload->data(), payload->size(), maskingKey); } /*! |