diff options
fix: Replace mallocs with new
2 files changed, 3 insertions, 3 deletions
| -rw-r--r-- | src/frame.cpp | 2 | ||||
| -rw-r--r-- | src/message.cpp | 4 |
diff --git a/src/frame.cpp b/src/frame.cpp index 9844099..05ec58d 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -51,7 +51,7 @@ void Frame::parse_frame_str(const unsigned char* iso_tp_frame) { break; } - this->data = (unsigned char*)malloc(sizeof(unsigned char) * this->data_size); + this->data = new unsigned char[this->data_size]; for (int i = 0; i < this->data_size; ++i) { this->data[i] = next_hex_byte(iso_tp_frame); } diff --git a/src/message.cpp b/src/message.cpp index 809a58b..af3168c 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -3,12 +3,12 @@ Message::Message(unsigned int can_id, const Frame& first_frame) : can_id(can_id), received(0) { this->size = first_frame.get_size(); - this->msg = (unsigned char*)malloc(sizeof(unsigned char) * this->size); + this->msg = new unsigned char[this->size]; this->receive_frame(first_frame); } Message::Message(const Message& rhs) : can_id(rhs.can_id), size(rhs.size), received(rhs.received) { - this->msg = (unsigned char*)malloc(sizeof(unsigned char) * this->size); + this->msg = new unsigned char[this->size]; std::memcpy(this->msg, rhs.msg, this->size); } |
