Just hardening the code with asserts.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 18 Nov 2011 02:09:55 +0000 (00:09 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 18 Nov 2011 02:09:55 +0000 (00:09 -0200)
src/host/messagepayload.cpp

index b9c1753..e23dfa4 100644 (file)
@@ -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<char *>( 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<const char *>( Payload.get() );
 
     (void) os.write( data_array, PayloadSizeInBytes );