#include "tao/Queued_Data.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"
#include "ace/Malloc_Base.h"
Go to the source code of this file.
Functions | |
static ACE_Message_Block * | clone_mb_nocopy_size (ACE_Message_Block *mb, size_t span_size) |
Allocate and return a new empty message block of size span_size mimicking parameters of mb. |
static ACE_Message_Block* clone_mb_nocopy_size | ( | ACE_Message_Block * | mb, | |
size_t | span_size | |||
) | [static] |
Allocate and return a new empty message block of size span_size mimicking parameters of mb.
This function allocates a new aligned message block using the same allocators and flags as found in mb. The size of the new message block is at least span_size; the size may be adjusted up in order to accomodate alignment requirements and still fit span_size bytes into the aligned buffer.
mb | message block whose parameters should be mimicked | |
span_size | size of the new message block (will be adjusted for proper alignment) |
Definition at line 34 of file Queued_Data.cpp.
{ // Calculate the required size of the cloned block with alignment size_t const aligned_size = ACE_CDR::first_size (span_size + ACE_CDR::MAX_ALIGNMENT); // Get the allocators ACE_Allocator *data_allocator = 0; ACE_Allocator *data_block_allocator = 0; ACE_Allocator *message_block_allocator = 0; mb->access_allocators (data_allocator, data_block_allocator, message_block_allocator); // Create a new Message Block ACE_Message_Block *nb = 0; ACE_NEW_MALLOC_RETURN (nb, static_cast<ACE_Message_Block*> ( message_block_allocator->malloc ( sizeof (ACE_Message_Block))), ACE_Message_Block(aligned_size, mb->msg_type(), mb->cont(), 0, //we want the data block created data_allocator, mb->locking_strategy(), mb->msg_priority(), mb->msg_execution_time (), mb->msg_deadline_time (), data_block_allocator, message_block_allocator), 0); ACE_CDR::mb_align (nb); // Copy the flags over, but be SURE to clear the DONT_DELETE flag, since // we just dynamically allocated the two things. nb->set_flags (mb->flags()); nb->clr_flags (ACE_Message_Block::DONT_DELETE); return nb; }