From 9b7409e51d3357677174f44fbeab7aaf1863fa4b Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Fri, 18 Nov 2011 00:09:55 -0200 Subject: [PATCH] Just hardening the code with asserts. --- src/host/messagepayload.cpp | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/src/host/messagepayload.cpp b/src/host/messagepayload.cpp index b9c1753..e23dfa4 100644 --- a/src/host/messagepayload.cpp +++ b/src/host/messagepayload.cpp @@ -24,7 +24,7 @@ using I2n::Logger::GlobalLogger; /** * @brief Parameterized constructor. * - * @param payload_size_in_bytes the size of the payload (ie the internal buffer) + * @param payload_size_in_bytes the size of the payload (i.e. the internal buffer) */ MessagePayload::MessagePayload( const std::size_t &payload_size_in_bytes @@ -58,6 +58,9 @@ MessagePayload::MessagePayload( BOOST_ASSERT( PayloadSizeInBytes == other.PayloadSizeInBytes ); } +/** + * @brief Destructor. + */ MessagePayload::~MessagePayload() { // The Payload is automatically deleted when the smart pointer's scope ends @@ -306,6 +309,8 @@ void MessagePayload::encode32( */ istream& MessagePayload::read( istream &is ) { + BOOST_ASSERT( Payload.get() != NULL ); + char *payload_data_array = reinterpret_cast( Payload.get() ); (void) is.read( payload_data_array, PayloadSizeInBytes ); @@ -330,6 +335,8 @@ istream& MessagePayload::read( istream &is ) */ ostream& MessagePayload::write( ostream &os ) const { + BOOST_ASSERT( Payload.get() != NULL ); + const char *data_array = reinterpret_cast( Payload.get() ); (void) os.write( data_array, PayloadSizeInBytes ); -- 1.7.1