diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
| commit | 9d40c47799bbec12bb02f7579736fbc1fcc35c08 (patch) | |
| tree | 0ef02a9f17d6550667aa745829ff5146b1ccf6a6 /src/BtPortMessage.cc | |
| parent | 9727b5b256bb12cff42e6aa230ba2020a933562f (diff) | |
| parent | 0b906f40f1204e79cb43af3867468ab02a371075 (diff) | |
Merge branch 'master' into dynamic-select-file
Diffstat (limited to 'src/BtPortMessage.cc')
| -rw-r--r-- | src/BtPortMessage.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/BtPortMessage.cc b/src/BtPortMessage.cc index 99b0d699..6a6c8d0f 100644 --- a/src/BtPortMessage.cc +++ b/src/BtPortMessage.cc @@ -100,7 +100,7 @@ void BtPortMessage::doReceivedAction() } } -unsigned char* BtPortMessage::createMessage() +std::vector<unsigned char> BtPortMessage::createMessage() { /** * len --- 5, 4bytes @@ -108,14 +108,12 @@ unsigned char* BtPortMessage::createMessage() * port --- port number, 2bytes * total: 7bytes */ - auto msg = new unsigned char[MESSAGE_LENGTH]; - bittorrent::createPeerMessageString(msg, MESSAGE_LENGTH, 3, ID); + auto msg = std::vector<unsigned char>(MESSAGE_LENGTH); + bittorrent::createPeerMessageString(msg.data(), MESSAGE_LENGTH, 3, ID); bittorrent::setShortIntParam(&msg[5], port_); return msg; } -size_t BtPortMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string BtPortMessage::toString() const { return fmt("%s port=%u", NAME, port_); |
