diff options
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(), |
