diff options
Diffstat (limited to 'ace/Message_Block.cpp')
-rw-r--r-- | ace/Message_Block.cpp | 185 |
1 files changed, 46 insertions, 139 deletions
diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index 87e4271b777..0b890748dc8 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -213,21 +213,6 @@ ACE_Message_Block::size (size_t length) return 0; } -size_t -ACE_Message_Block::total_size (void) const -{ - ACE_TRACE ("ACE_Message_Block::total_size"); - - size_t s = 0; - - for (ACE_Message_Block *temp = ACE_const_cast (ACE_Message_Block *, this); - temp != 0; - temp = temp->cont ()) - s += temp->size (); - - return s; -} - ACE_Data_Block::ACE_Data_Block (void) : type_ (ACE_Message_Block::MB_DATA), cur_size_ (0), @@ -298,13 +283,12 @@ ACE_Message_Block::ACE_Message_Block (const char *data, ACE_Time_Value::zero, // execution time ACE_Time_Value::max_time, // absolute time of deadline 0, // data block - 0, // data_block allocator - 0) == -1) // message_block allocator + 0) == -1) // data_block allocator ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block"))); } -ACE_Message_Block::ACE_Message_Block (ACE_Allocator *message_block_allocator) +ACE_Message_Block::ACE_Message_Block (void) : data_block_ (0) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); @@ -320,8 +304,7 @@ ACE_Message_Block::ACE_Message_Block (ACE_Allocator *message_block_allocator) ACE_Time_Value::zero, // execution time ACE_Time_Value::max_time, // absolute time of deadline 0, // data block - 0, // data_block allocator - message_block_allocator) == -1) // message_block allocator + 0) == -1) // data_block allocator ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block"))); } @@ -335,8 +318,7 @@ ACE_Message_Block::ACE_Message_Block (size_t size, u_long priority, const ACE_Time_Value & execution_time, const ACE_Time_Value & deadline_time, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator) + ACE_Allocator *data_block_allocator) : data_block_ (0) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); @@ -352,8 +334,7 @@ ACE_Message_Block::ACE_Message_Block (size_t size, execution_time, deadline_time, 0, // data block - data_block_allocator, - message_block_allocator) == -1) + data_block_allocator) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block"))); } @@ -368,8 +349,7 @@ ACE_Message_Block::init (size_t size, u_long priority, const ACE_Time_Value & execution_time, const ACE_Time_Value & deadline_time, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator) + ACE_Allocator *data_block_allocator) { ACE_TRACE ("ACE_Message_Block::init"); @@ -384,8 +364,7 @@ ACE_Message_Block::init (size_t size, execution_time, deadline_time, 0, // data block - data_block_allocator, - message_block_allocator); + data_block_allocator); } int @@ -406,8 +385,7 @@ ACE_Message_Block::init (const char *data, ACE_Time_Value::zero, // execution time ACE_Time_Value::max_time, // absolute time of deadline 0, // data block - 0, // data_block allocator - 0); // message_block allocator + 0); } ACE_Message_Block::ACE_Message_Block (size_t size, @@ -421,8 +399,7 @@ ACE_Message_Block::ACE_Message_Block (size_t size, const ACE_Time_Value & execution_time, const ACE_Time_Value & deadline_time, ACE_Data_Block *db, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator) + ACE_Allocator *data_block_allocator) : data_block_ (0) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); @@ -438,14 +415,12 @@ ACE_Message_Block::ACE_Message_Block (size_t size, execution_time, deadline_time, db, - data_block_allocator, - message_block_allocator) == -1) + data_block_allocator) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block"))); } -ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block, - ACE_Allocator *message_block_allocator) +ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block) : data_block_ (0) { ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); @@ -460,9 +435,8 @@ ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block, 0, // priority ACE_Time_Value::zero, // execution time ACE_Time_Value::max_time, // absolute time of deadline - data_block, // data block - data_block->data_block_allocator (), - message_block_allocator) == -1) + data_block, + data_block->data_block_allocator ()) == -1) // data block ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block"))); } @@ -479,8 +453,7 @@ ACE_Message_Block::init_i (size_t size, const ACE_Time_Value & execution_time, const ACE_Time_Value & deadline_time, ACE_Data_Block *db, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator) + ACE_Allocator *data_block_allocator) { ACE_TRACE ("ACE_Message_Block::init_i"); ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER); @@ -494,8 +467,6 @@ ACE_Message_Block::init_i (size_t size, this->next_ = 0; this->prev_ = 0; - this->message_block_allocator_ = message_block_allocator; - if (this->data_block_ != 0) { this->data_block_->release (); @@ -712,13 +683,8 @@ ACE_Message_Block::release_i (ACE_Lock *lock) } // We will now commit suicide: this object *must* have come from the - // allocator given. - if (this->message_block_allocator_ == 0) - delete this; - else - ACE_DES_FREE (this, - message_block_allocator_->free, - ACE_Message_Block); + // heap. + delete this; return result; } @@ -774,50 +740,24 @@ ACE_Message_Block::duplicate (void) const // Create a new <ACE_Message_Block> that contains unique copies of // the message block fields, but a reference counted duplicate of // the <ACE_Data_Block>. - - // If there is no allocator, use the standard new and delete calls. - if (this->message_block_allocator_ == 0) - ACE_NEW_RETURN (nb, - ACE_Message_Block (0, // size - ACE_Message_Type (0), // type - 0, // cont - 0, // data - 0, // allocator - 0, // locking strategy - 0, // flags - this->priority_, // priority - this->execution_time_, // execution time - this->deadline_time_, // absolute time to deadline - // Get a pointer to a - // "duplicated" <ACE_Data_Block> - // (will simply increment the - // reference count). - this->data_block ()->duplicate (), - this->data_block ()->data_block_allocator (), - this->message_block_allocator_), + ACE_NEW_RETURN (nb, + ACE_Message_Block (0, // size + ACE_Message_Type (0), // type + 0, // cont + 0, // data + 0, // allocator + 0, // locking strategy + 0, // flags + this->priority_, // priority + this->execution_time_, // execution time + this->deadline_time_, // absolute time to deadline + // Get a pointer to a + // "duplicated" <ACE_Data_Block> + // (will simply increment the + // reference count). + this->data_block ()->duplicate (), + this->data_block ()->data_block_allocator ()), 0); - else // Otherwise, use the message_block_allocator passed in. - ACE_NEW_MALLOC_RETURN (nb, - ACE_reinterpret_cast(ACE_Message_Block*, - message_block_allocator_->malloc (sizeof (ACE_Message_Block))), - ACE_Message_Block (0, // size - ACE_Message_Type (0), // type - 0, // cont - 0, // data - 0, // allocator - 0, // locking strategy - 0, // flags - this->priority_, // priority - this->execution_time_, // execution time - this->deadline_time_, // absolute time to deadline - // Get a pointer to a - // "duplicated" <ACE_Data_Block> - // (will simply increment the - // reference count). - this->data_block ()->duplicate (), - this->data_block ()->data_block_allocator (), - this->message_block_allocator_), - 0); // Set the read and write pointers in the new <Message_Block> to the // same relative offset as in the existing <Message_Block>. Note @@ -899,52 +839,19 @@ ACE_Message_Block::clone (Message_Flags mask) const if (db == 0) return 0; - ACE_Message_Block *nb; - - if(message_block_allocator_ == 0) - { - nb = new ACE_Message_Block (0, // size - ACE_Message_Type (0), // type - 0, // cont - 0, // data - 0, // allocator - 0, // locking strategy - 0, // flags - this->priority_, // priority - this->execution_time_, // execution time - this->deadline_time_, // absolute time to deadline - // Get a pointer to a - // "duplicated" <ACE_Data_Block> - // (will simply increment the - // reference count). - db, - db->data_block_allocator (), - this->message_block_allocator_); - } - else - { - // This is the ACE_NEW_MALLOC macro with the return check removed. - // We need to do it this way because if it fails we need to release - // the cloned data block that was created above. If we used - // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the - // above db pointer would be left dangling. - nb = ACE_static_cast(ACE_Message_Block*,message_block_allocator_->malloc (sizeof (ACE_Message_Block))); - if(nb != 0) - new (nb) ACE_Message_Block (0, // size - ACE_Message_Type (0), // type - 0, // cont - 0, // data - 0, // allocator - 0, // locking strategy - 0, // flags - this->priority_, // priority - this->execution_time_, // execution time - this->deadline_time_, // absolute time to deadline - db, - db->data_block_allocator(), - this->message_block_allocator_); - } - + ACE_Message_Block *nb = + new ACE_Message_Block (0, // size + ACE_Message_Type (0), // type + 0, // cont + 0, // data + 0, // allocator + 0, // locking strategy + 0, // flags + this->priority_, // priority + this->execution_time_, // execution time + this->deadline_time_, // absolute time to deadline + db, // data_block + db->data_block_allocator ()); if (nb == 0) { db->release (); |