ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor (const ACE_TCHAR service_name[], const ACE_TCHAR service_description[], int use_select, int reuse_addr) : creation_strategy_ (0), delete_creation_strategy_ (0), accept_strategy_ (0), delete_accept_strategy_ (0), concurrency_strategy_ (0), delete_concurrency_strategy_ (0), scheduling_strategy_ (0), delete_scheduling_strategy_ (0), service_name_ (0), service_description_ (0) { ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); if (service_name != 0) ACE_ALLOCATOR (this->service_name_, ACE_OS::strdup (service_name)); if (service_description != 0) ACE_ALLOCATOR (this->service_description_, ACE_OS::strdup (service_description)); this->use_select_ = use_select; this->reuse_addr_ = reuse_addr; }
ACE_Data_Block::ACE_Data_Block (size_t size, ACE_Message_Block::ACE_Message_Type msg_type, const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, ACE_Message_Block::Message_Flags flags, ACE_Allocator *data_block_allocator) : type_ (msg_type), cur_size_ (0), // Reset later if memory alloc'd ok max_size_ (0), flags_ (flags), base_ (const_cast <char *> (msg_data)), allocator_strategy_ (allocator_strategy), locking_strategy_ (locking_strategy), reference_count_ (1), data_block_allocator_ (data_block_allocator) { ACE_TRACE ("ACE_Data_Block::ACE_Data_Block"); ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER); // If the user didn't pass one in, let's use the // <ACE_Allocator::instance>. if (this->allocator_strategy_ == 0) ACE_ALLOCATOR (this->allocator_strategy_, ACE_Allocator::instance ()); if (this->data_block_allocator_ == 0) ACE_ALLOCATOR (this->data_block_allocator_, ACE_Allocator::instance ()); if (msg_data == 0) { ACE_ALLOCATOR (this->base_, (char *) this->allocator_strategy_->malloc (size)); #if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE) (void) ACE_OS::memset (this->base_, '\0', size); #endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */ } // ACE_ALLOCATOR returns on alloc failure but we cant throw, so setting // the size to 0 (i.e. "bad bit") ... if (this->base_ == 0) { size = 0; } // The memory is legit, whether passed in or allocated, so set // the size. this->cur_size_ = this->max_size_ = size; }
template <class T> void ACE_Array_Base<T>::operator= (const ACE_Array_Base<T> &s) { // Check for "self-assignment". if (this != &s) { if (this->max_size_ < s.size ()) { ACE_DES_ARRAY_FREE (this->array_, this->max_size_, this->allocator_->free, T); ACE_ALLOCATOR (this->array_, (T *) this->allocator_->malloc (s.size () * sizeof (T))); this->max_size_ = s.size (); } else { ACE_DES_ARRAY_NOFREE (this->array_, s.size (), T); } this->cur_size_ = s.size (); for (size_t i = 0; i < this->size (); i++) new (&this->array_[i]) T (s.array_[i]); } }
// this method might benefit from a little restructuring. template <class ACE_CHAR_T> void ACE_String_Base<ACE_CHAR_T>::set (const ACE_CHAR_T *s, typename ACE_String_Base<ACE_CHAR_T>::size_type len, bool release) { // Case 1. Going from memory to more memory size_type new_buf_len = len + 1; if (s != 0 && len != 0 && release && this->buf_len_ < new_buf_len) { ACE_CHAR_T *temp = 0; ACE_ALLOCATOR (temp, (ACE_CHAR_T *) this->allocator_->malloc (new_buf_len * sizeof (ACE_CHAR_T))); if (this->buf_len_ != 0 && this->release_) this->allocator_->free (this->rep_); this->rep_ = temp; this->buf_len_ = new_buf_len; this->release_ = true; this->len_ = len; ACE_OS::memcpy (this->rep_, s, len * sizeof (ACE_CHAR_T)); this->rep_[len] = 0; } else // Case 2. No memory allocation is necessary. { // Free memory if necessary and figure out future ownership if (!release || s == 0 || len == 0) { if (this->buf_len_ != 0 && this->release_) { this->allocator_->free (this->rep_); this->release_ = false; } } // Populate data. if (s == 0 || len == 0) { this->buf_len_ = 0; this->len_ = 0; this->rep_ = &ACE_String_Base<ACE_CHAR_T>::NULL_String_; this->release_ = false; } else if (!release) // Note: No guarantee that rep_ is null terminated. { this->buf_len_ = len; this->len_ = len; this->rep_ = const_cast <ACE_CHAR_T *> (s); this->release_ = false; } else { ACE_OS::memcpy (this->rep_, s, len * sizeof (ACE_CHAR_T)); this->rep_[len] = 0; this->len_ = len; } } }
Grid_i::Grid_i (CORBA::Short x, CORBA::Short y, pool_t *mem_pool) : width_ (x), height_ (y), array_ (0), pool_t_ (0) { // First try to locate the matrix in the pool. If it is there then // it has already been created. In such a case we just get that // memory and assign it to array_ void *tmp_array (0); if (mem_pool->find ("Array", tmp_array) != -1) { array_ = reinterpret_cast <CORBA::Long **> (tmp_array); } else { // Allocate memory for the matrix. ACE_ALLOCATOR (array_, static_cast<CORBA::Long **> (mem_pool->malloc (y * sizeof (CORBA::Long *)))); //array_ = (CORBA::Long **) mem_pool->malloc (y * sizeof (CORBA::Long *)); if (array_ != 0) { for (int ctr = 0; ctr < y; ctr++) { ACE_ALLOCATOR (array_[ctr], static_cast<CORBA::Long *> (mem_pool->malloc (x * sizeof (CORBA::Long )))); //array_[ctr] = (CORBA::Long *)mem_pool->malloc (x * // sizeof (CORBA::Long)); } mem_pool->bind ("Array", array_); } } }
ACE_Data_Block::ACE_Data_Block (void) : type_ (ACE_Message_Block::MB_DATA), cur_size_ (0), max_size_ (0), flags_ (ACE_Message_Block::DONT_DELETE), base_ (0), allocator_strategy_ (0), locking_strategy_ (0), reference_count_ (1), data_block_allocator_ (0) { ACE_TRACE ("ACE_Data_Block::ACE_Data_Block"); ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER); ACE_ALLOCATOR (this->allocator_strategy_, ACE_Allocator::instance ()); ACE_ALLOCATOR (this->data_block_allocator_, ACE_Allocator::instance ()); }
ACE_Array_Base<T>::ACE_Array_Base (const ACE_Array_Base<T> &s) : max_size_ (s.size ()), cur_size_ (s.size ()), allocator_ (s.allocator_) { if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); ACE_ALLOCATOR (this->array_, (T *) this->allocator_->malloc (s.size () * sizeof (T))); for (size_t i = 0; i < this->size (); i++) new (&this->array_[i]) T (s.array_[i]); }
ACE_Obstack_T<ACE_CHAR_T>::ACE_Obstack_T (size_t size, ACE_Allocator *allocator_strategy) : allocator_strategy_ (allocator_strategy), size_ (size), head_ (0), curr_ (0) { ACE_TRACE ("ACE_Obstack_T<ACE_CHAR_T>::ACE_Obstack"); if (this->allocator_strategy_ == 0) ACE_ALLOCATOR (this->allocator_strategy_, ACE_Allocator::instance ()); this->head_ = this->new_chunk (); this->curr_ = this->head_; }
ACE_Array_Base<T>::ACE_Array_Base (size_t size, ACE_Allocator *alloc) : max_size_ (size), cur_size_ (size), allocator_ (alloc) { if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); if (size != 0) { ACE_ALLOCATOR (this->array_, (T *) this->allocator_->malloc (size * sizeof (T))); for (size_t i = 0; i < size; ++i) new (&array_[i]) T; } else this->array_ = 0; }
ACE_NS_WString::ACE_NS_WString (const char *s, ACE_Allocator *alloc) : ACE_WString (alloc) { if (s == 0) return; this->len_ = this->buf_len_ = ACE_OS::strlen (s); if (this->buf_len_ == 0) return; ACE_ALLOCATOR (this->rep_, (ACE_WSTRING_TYPE *) this->allocator_->malloc ((this->buf_len_ + 1) * sizeof (ACE_WSTRING_TYPE))); this->release_ = 1; for (size_type i = 0; i <= this->buf_len_; ++i) this->rep_[i] = s[i]; }
ACE_NS_WString::ACE_NS_WString (const ACE_UINT16 *s, size_type len, ACE_Allocator *alloc) : ACE_WString (alloc) { if (s == 0) return; this->buf_len_ = len; if (this->buf_len_ == 0) return; ACE_ALLOCATOR (this->rep_, (ACE_WSTRING_TYPE *) this->allocator_->malloc ((this->buf_len_) * sizeof (ACE_WSTRING_TYPE))); this->release_ = 1; for (size_type i = 0; i < this->buf_len_; ++i) this->rep_[i] = s[i]; }