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/RangeBtMessage.cc | |
| parent | 9727b5b256bb12cff42e6aa230ba2020a933562f (diff) | |
| parent | 0b906f40f1204e79cb43af3867468ab02a371075 (diff) | |
Merge branch 'master' into dynamic-select-file
Diffstat (limited to 'src/RangeBtMessage.cc')
| -rw-r--r-- | src/RangeBtMessage.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index 5cf3940c..ffda1801 100644 --- a/src/RangeBtMessage.cc +++ b/src/RangeBtMessage.cc @@ -45,7 +45,7 @@ RangeBtMessage::RangeBtMessage(uint8_t id, const char* name, size_t index, { } -unsigned char* RangeBtMessage::createMessage() +std::vector<unsigned char> RangeBtMessage::createMessage() { /** * len --- 13, 4bytes @@ -55,16 +55,14 @@ unsigned char* RangeBtMessage::createMessage() * length -- length, 4bytes * total: 17bytes */ - auto msg = new unsigned char[MESSAGE_LENGTH]; - bittorrent::createPeerMessageString(msg, MESSAGE_LENGTH, 13, getId()); + auto msg = std::vector<unsigned char>(MESSAGE_LENGTH); + bittorrent::createPeerMessageString(msg.data(), MESSAGE_LENGTH, 13, getId()); bittorrent::setIntParam(&msg[5], index_); bittorrent::setIntParam(&msg[9], begin_); bittorrent::setIntParam(&msg[13], length_); return msg; } -size_t RangeBtMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string RangeBtMessage::toString() const { return fmt("%s index=%lu, begin=%d, length=%d", getName(), |
