[network/libktorrent] src/utp/tests: Remove manual memory allocation from sendtest
Jack Hill <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 645bff7aeb16de5685683546f9c5af3891c3b068 by Jack Hill.
Committed on 22/07/2026 at 20:11.
Pushed by jackh into branch 'master'.
Remove manual memory allocation from sendtest
Use vector instead of new array.
M +5 -6 src/utp/tests/sendtest.cpp
https://invent.kde.org/network/libktorrent/-/commit/645bff7aeb16de5685683546f9c5af3891c3b068
diff --git a/src/utp/tests/sendtest.cpp b/src/utp/tests/sendtest.cpp
index 11926909..592e162f 100644
--- a/src/utp/tests/sendtest.cpp
+++ b/src/utp/tests/sendtest.cpp
@@ -5,6 +5,7 @@
*/
#include <array>
+#include <vector>
#include <QObject>
#include <QTest>
@@ -102,12 +103,10 @@ private:
constexpr std::array<bt::Uint8, 1000> sdata{0xFF};
outgoing->send(sdata);
- bt::Uint8 *rdata = new bt::Uint8[1000];
- const int ret = incoming->recv(rdata, 1000);
- QCOMPARE(ret, 1000);
- QCOMPARE(memcmp(sdata.data(), rdata, ret), 0);
-
- delete[] rdata;
+ std::vector<bt::Uint8> rdata(1000);
+ const int ret = incoming->recv(rdata.data(), rdata.size());
+ QCOMPARE(ret, rdata.size());
+ QCOMPARE(memcmp(sdata.data(), rdata.data(), ret), 0);
}
void testSend3()