diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-15 23:40:09 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-15 23:40:52 +0900 |
| commit | a7237c69f7befce7af174087bf770acd0187fb9b (patch) | |
| tree | c91ede2c506785956c55bfad0dce82a0c73ceea2 /src/RangeBtMessage.cc | |
| parent | cc8375f0b04918ace028bf58e09f9e25a0440c23 (diff) | |
Refactor BitTorrent message buffer usage
Diffstat (limited to 'src/RangeBtMessage.cc')
| -rw-r--r-- | src/RangeBtMessage.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index 5cf3940c..2f811ce7 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,8 +55,8 @@ 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_); |
