diff options
Diffstat (limited to 'ace')
49 files changed, 1054 insertions, 1034 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index a2c91eae749..794e7db5401 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -134,7 +134,7 @@ ACE::terminate_process (pid_t pid) pid); if (process_handle == ACE_INVALID_HANDLE - || process_handle == NULL) + || process_handle == 0) return -1; else { @@ -175,7 +175,7 @@ ACE::process_active (pid_t pid) ACE_HANDLE process_handle = ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); if (process_handle == ACE_INVALID_HANDLE - || process_handle == NULL) + || process_handle == 0) return 0; else { @@ -1046,7 +1046,9 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -1082,7 +1084,9 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -3122,8 +3126,8 @@ ACE::get_ip_interfaces (size_t &count, 0, 0, info, sizeof(info), &bytes, - NULL, - NULL); + 0, + 0); closesocket (sock); if (status == SOCKET_ERROR) return -1; @@ -3132,7 +3136,9 @@ ACE::get_ip_interfaces (size_t &count, if (n_interfaces == 0) return 0; - ACE_NEW_RETURN (addrs, ACE_INET_Addr[n_interfaces], -1); + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[n_interfaces], + -1); // Now go through the list and transfer the good ones to the list of // because they're down or don't have an IP address. @@ -3164,55 +3170,73 @@ ACE::get_ip_interfaces (size_t &count, #else /* Winsock 2 && MSVC 5 or later */ - // PharLap ETS has kernel routines to rummage through the device configs - // and extract the interface info. Sort of a pain in the butt, but better - // than trying to figure out where it moved to in the registry... :-| + // PharLap ETS has kernel routines to rummage through the device + // configs and extract the interface info. Sort of a pain in the + // butt, but better than trying to figure out where it moved to in + // the registry... :-| # if defined (ACE_HAS_PHARLAP) # if !defined (ACE_HAS_PHARLAP_RT) ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PHARLAP_RT */ - // Locate all of the IP devices in the system, saving a DEVHANDLE for - // each. Then allocate the ACE_INET_Addrs needed and fetch all the IP - // addresses. - // To locate the devices, try the available device name roots and increment - // the device number until the kernel says there are no more of that type. - const size_t ACE_MAX_ETS_DEVICES = 64; /* Arbitrary, but should be enough */ - DEVHANDLE ip_dev[ACE_MAX_ETS_DEVICES]; + // Locate all of the IP devices in the system, saving a DEVHANDLE + // for each. Then allocate the ACE_INET_Addrs needed and fetch all + // the IP addresses. To locate the devices, try the available + // device name roots and increment the device number until the + // kernel says there are no more of that type. + const size_t ACE_MAX_ETS_DEVICES = 64; // Arbitrary, but should be enough. + DEVHANDLE ip_dev[ACE_MAX_ETS_DEVICES]; EK_TCPIPCFG *devp; - size_t i, j; - char dev_name[16]; + size_t i, j; + char dev_name[16]; count = 0; for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) { - ACE_OS::sprintf (dev_name, "ether%d", i); /* Ethernet */ - if ((ip_dev[count] = EtsTCPGetDeviceHandle (dev_name)) == NULL) + // Ethernet. + ACE_OS::sprintf (dev_name, + "ether%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) break; } for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) { - ACE_OS::sprintf (dev_name, "sl%d", i); /* SLIP */ - if ((ip_dev[count] = EtsTCPGetDeviceHandle (dev_name)) == NULL) + // SLIP. + ACE_OS::sprintf (dev_name, + "sl%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) break; } for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) { - ACE_OS::sprintf (dev_name, "ppp%d", i); /* PPP */ - if ((ip_dev[count] = EtsTCPGetDeviceHandle (dev_name)) == NULL) + // PPP. + ACE_OS::sprintf (dev_name, + "ppp%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) break; } if (count > 0) - addrs = new ACE_INET_Addr[count]; + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[count], + -1); else addrs = 0; for (i = 0, j = 0; i < count; i++) { - if ((devp = EtsTCPGetDeviceCfg (ip_dev[i])) != NULL) + devp = EtsTCPGetDeviceCfg (ip_dev[i]); + if (devp != 0) { - addrs[j].set (0, devp->nwIPAddress, 0); /* Already in net order */ + addrs[j].set (0, + devp->nwIPAddress, + 0); // Already in net order. j++; } // There's no call to close the DEVHANDLE. @@ -3248,14 +3272,14 @@ ACE::get_ip_interfaces (size_t &count, raw_buffer, raw_buflen)) return -1; - // return buffer contains NULL delimited strings + // return buffer contains 0 delimited strings ACE_Tokenizer dev_names (raw_buffer); dev_names.delimiter (ACE_TEXT('\0')); int n_interfaces = 0; // Count the number of interfaces - while (dev_names.next () != NULL) + while (dev_names.next () != 0) n_interfaces ++; // case 1. no interfaces present, empty string? OS version change? diff --git a/ace/ARGV.cpp b/ace/ARGV.cpp index 73460c87b44..27a54e26f0b 100644 --- a/ace/ARGV.cpp +++ b/ace/ARGV.cpp @@ -115,7 +115,8 @@ ACE_ARGV::ACE_ARGV (ASYS_TCHAR *argv[], // Step through all argv params and copy each one into buf; separate // each param with white space. - ACE_NEW (this->buf_, ASYS_TCHAR[buf_len + 1]); + ACE_NEW (this->buf_, + ASYS_TCHAR[buf_len + 1]); ASYS_TCHAR *end = this->buf_; int j; @@ -174,7 +175,8 @@ ACE_ARGV::ACE_ARGV (ASYS_TCHAR *first_argv[], int buf_len = ACE_OS::strlen (first_buf) + ACE_OS::strlen (second_buf) + 1; // Allocate memory to the lenght of the combined argv string. - ACE_NEW (this->buf_, ASYS_TCHAR[buf_len + 1]); + ACE_NEW (this->buf_, + ASYS_TCHAR[buf_len + 1]); // copy the first argv string to the buffer ACE_OS::strcpy (this->buf_,first_buf); diff --git a/ace/Asynch_Acceptor.cpp b/ace/Asynch_Acceptor.cpp index 8426eb22f58..13c3153915c 100644 --- a/ace/Asynch_Acceptor.cpp +++ b/ace/Asynch_Acceptor.cpp @@ -411,7 +411,9 @@ ACE_Asynch_Acceptor<HANDLER>::make_handler (void) { // Default behavior HANDLER *handler = 0; - ACE_NEW_RETURN (handler, HANDLER, 0); + ACE_NEW_RETURN (handler, + HANDLER, + 0); return handler; } diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp index c1c0b71a122..9220778588b 100644 --- a/ace/CDR_Stream.cpp +++ b/ace/CDR_Stream.cpp @@ -736,7 +736,9 @@ ACE_InputCDR::read_string (char *&x) this->read_ulong (len); if (len > 0) { - ACE_NEW_RETURN (x, ACE_CDR::Char[len], 0); + ACE_NEW_RETURN (x, + ACE_CDR::Char[len], + 0); if (this->read_char_array (x, len)) return 1; delete [] x; @@ -774,7 +776,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) this->read_ulong (len); if (this->good_bit()) { - ACE_NEW_RETURN (x, ACE_CDR::WChar[len], 0); + ACE_NEW_RETURN (x, + ACE_CDR::WChar[len], + 0); if (this->read_wchar_array (x, len)) return 1; diff --git a/ace/CORBA_Handler.cpp b/ace/CORBA_Handler.cpp index 1e74d6c21c5..5ae478cc84e 100644 --- a/ace/CORBA_Handler.cpp +++ b/ace/CORBA_Handler.cpp @@ -306,7 +306,9 @@ ACE_ST_CORBA_Handler::instance (void) if (ACE_ST_CORBA_Handler::instance_ == 0) { - ACE_NEW_RETURN (ACE_ST_CORBA_Handler::instance_, ACE_ST_CORBA_Handler, 0); + ACE_NEW_RETURN (ACE_ST_CORBA_Handler::instance_, + ACE_ST_CORBA_Handler, + 0); ACE_ST_CORBA_Handler::instance_->get_orbix_descriptors (); } diff --git a/ace/Containers_T.cpp b/ace/Containers_T.cpp index e5c4d04a295..9956bdcdb52 100644 --- a/ace/Containers_T.cpp +++ b/ace/Containers_T.cpp @@ -32,7 +32,8 @@ ACE_Bounded_Stack<T>::ACE_Bounded_Stack (size_t size) : top_ (0), size_ (size) { - ACE_NEW (this->stack_, T[size]); + ACE_NEW (this->stack_, + T[size]); ACE_TRACE ("ACE_Bounded_Stack<T>::ACE_Bounded_Stack"); } @@ -41,7 +42,8 @@ ACE_Bounded_Stack<T>::ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s) : top_ (s.top_), size_ (s.size_) { - ACE_NEW (this->stack_, T[s.size_]); + ACE_NEW (this->stack_, + T[s.size_]); ACE_TRACE ("ACE_Bounded_Stack<T>::ACE_Bounded_Stack"); @@ -1486,8 +1488,8 @@ ACE_Bounded_Set<T>::operator= (const ACE_Bounded_Set<T> &bs) if (this->max_size_ < bs.cur_size_) { delete [] this->search_structure_; - ACE_NEW (this->search_structure_, ACE_TYPENAME - ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]); + ACE_NEW (this->search_structure_, + ACE_TYPENAME ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]); this->max_size_ = bs.cur_size_; } diff --git a/ace/DEV_IO.cpp b/ace/DEV_IO.cpp index de00433333d..2b9e86f370e 100644 --- a/ace/DEV_IO.cpp +++ b/ace/DEV_IO.cpp @@ -66,7 +66,9 @@ ACE_DEV_IO::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -101,7 +103,9 @@ ACE_DEV_IO::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); diff --git a/ace/Dump.cpp b/ace/Dump.cpp index 6e578547bd3..7479f2489e1 100644 --- a/ace/Dump.cpp +++ b/ace/Dump.cpp @@ -63,7 +63,9 @@ ACE_ODB::instance (void) ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0)); if (ACE_ODB::instance_ == 0) - ACE_NEW_RETURN (ACE_ODB::instance_, ACE_ODB, 0); + ACE_NEW_RETURN (ACE_ODB::instance_, + ACE_ODB, + 0); } return ACE_ODB::instance_; diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 9f5a848bcce..353a8060672 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -44,7 +44,9 @@ ACE_FILE_IO::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -81,7 +83,9 @@ ACE_FILE_IO::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); diff --git a/ace/Filecache.cpp b/ace/Filecache.cpp index b92896f1b49..89a60e91cc4 100644 --- a/ace/Filecache.cpp +++ b/ace/Filecache.cpp @@ -203,7 +203,9 @@ ACE_Filecache::instance (void) // @@ James, please check each of the ACE_NEW_RETURN calls to // make sure that it is safe to return if allocation fails. if (ACE_Filecache::cvf_ == 0) - ACE_NEW_RETURN (ACE_Filecache::cvf_, ACE_Filecache, 0); + ACE_NEW_RETURN (ACE_Filecache::cvf_, + ACE_Filecache, + 0); } return ACE_Filecache::cvf_; diff --git a/ace/Future.cpp b/ace/Future.cpp index 173c56501ec..eb54be3b2fa 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -67,7 +67,11 @@ template <class T> ACE_Future_Rep<T> * ACE_Future_Rep<T>::create (void) { // Yes set ref count to zero. - return new ACE_Future_Rep<T> (); + ACE_Future_Rep<T> *t = 0; + ACE_NEW_RETURN (t, + ACE_Future_Rep<T>, + 0); + return t; } template <class T> ACE_Future_Rep<T> * diff --git a/ace/IOStream.cpp b/ace/IOStream.cpp index 0603f926060..b77fc6c57dd 100644 --- a/ace/IOStream.cpp +++ b/ace/IOStream.cpp @@ -559,7 +559,9 @@ ACE_Streambuf::reset_get_buffer (char *newBuffer, this->eback_saved_ = newBuffer; } else - ACE_NEW_RETURN (this->eback_saved_, char[streambuf_size_], 0); + ACE_NEW_RETURN (this->eback_saved_, + char[streambuf_size_], + 0); this->gptr_saved_ = this->eback_saved_ + _gptr; this->egptr_saved_ = this->eback_saved_ + _egptr; @@ -606,7 +608,9 @@ ACE_Streambuf::reset_put_buffer (char *newBuffer, this->pbase_saved_ = newBuffer; } else - ACE_NEW_RETURN (this->pbase_saved_, char[streambuf_size_], 0); + ACE_NEW_RETURN (this->pbase_saved_, + char[streambuf_size_], + 0); this->pptr_saved_ = this->pbase_saved_ + _pptr; this->epptr_saved_ = this->pbase_saved_ + streambuf_size_; diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index 37789a779a7..143fc3ae0d4 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -311,7 +311,9 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve_i (const ACE_WString &na // Makes a copy here. Caller needs to call delete to free up // memory. char *new_type; - ACE_NEW_RETURN (new_type, char [len + 1], -1); + ACE_NEW_RETURN (new_type, + char [len + 1], + -1); ACE_OS::strncpy (new_type, temp, len); new_type[len] = '\0'; // Null terminate the string @@ -439,7 +441,9 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void) if (ACE_LOG_MSG->op_status ()) ACE_ERROR_RETURN ((LM_ERROR, "Allocator::Allocator\n"), -1); - ACE_NEW_RETURN (this->lock_, ACE_LOCK (lock_name_for_local_name_space), -1); + ACE_NEW_RETURN (this->lock_, + ACE_LOCK (lock_name_for_local_name_space), + -1); #if !defined (ACE_LACKS_ACCESS) // Now check if the backing store has been created successfully diff --git a/ace/Local_Tokens.cpp b/ace/Local_Tokens.cpp index a5c1260f0b8..041e1cf1045 100644 --- a/ace/Local_Tokens.cpp +++ b/ace/Local_Tokens.cpp @@ -40,8 +40,6 @@ ACE_Tokens::make_owner (ACE_TPQ_Entry *caller) this->waiters_.enqueue (caller, 0); } -// ************************************************************ - #if defined (ACE_LACKS_INLINE_FUNCTIONS) ACE_Null_Token::ACE_Null_Token (void) { @@ -52,10 +50,6 @@ ACE_Null_Token::~ACE_Null_Token (void) } #endif /* ACE_LACKS_INLINE_FUNCTIONS */ -// ************************************************************ -// ************************************************************ - - void ACE_TPQ_Entry::dump (void) const { @@ -158,10 +152,6 @@ ACE_TPQ_Entry::client_id (const ASYS_TCHAR *id) this->client_id_[ACE_MAXCLIENTIDLEN - 1] = '\0'; } -// ************************************************************ -// ************************************************************ -// ************************************************************ - void ACE_TSS_TPQ_Entry::dump (void) const { @@ -195,7 +185,10 @@ ACE_TSS_TPQ_Entry::make_TSS_TYPE (void) const ACE_TRACE ("ACE_TSS_TPQ_Entry::make_TSS_TYPE"); ACE_TPQ_Entry *temp; - ACE_NEW_RETURN (temp, ACE_TPQ_Entry (this->proxy_, this->client_id_), 0); + ACE_NEW_RETURN (temp, + ACE_TPQ_Entry (this->proxy_, + this->client_id_), + 0); return temp; } @@ -205,10 +198,6 @@ ACE_TSS_TPQ_Entry::operator ACE_TPQ_Entry * (void) return (ACE_TPQ_Entry *) (*((ACE_TSS<ACE_TPQ_Entry> *) this)); } -// ************************************************************ -// ************************************************************ -// ************************************************************ - ACE_TPQ_Iterator::ACE_TPQ_Iterator (ACE_Token_Proxy_Queue &q) : current_ (q.head_) { @@ -254,10 +243,6 @@ ACE_TPQ_Iterator::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -// ************************************************************ -// ************************************************************ -// ************************************************************ - void ACE_Token_Proxy_Queue::dump (void) const { @@ -414,10 +399,6 @@ ACE_Token_Proxy_Queue::remove (const ACE_TPQ_Entry *remove_me) return; } -// ************************************************************ -// ************************************************************ -// ************************************************************ - void ACE_Mutex_Token::dump (void) const { @@ -653,10 +634,6 @@ ACE_Mutex_Token::is_owner (const ASYS_TCHAR *id) return 0; } -// ************************************************************ -// ************************************************************ -// ************************************************************ - void ACE_RW_Token::dump (void) const { @@ -1035,11 +1012,6 @@ ACE_RW_Token::is_owner (const ASYS_TCHAR *id) return 0; } -// ************************************************************ -// ************************************************************ -// ************************************************************ -// 7.. - void ACE_Token_Proxy::dump (void) const { @@ -1391,8 +1363,6 @@ ACE_Token_Proxy::token_acquired (ACE_TPQ_Entry *e) return; } -// ************************************************************ - ACE_Token_Name::ACE_Token_Name (const ASYS_TCHAR *token_name) { ACE_TRACE ("ACE_Token_Name::ACE_Token_Name"); diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 487b41e2fd3..70cf92c3d42 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -96,7 +96,9 @@ ACE_Log_Msg_Manager::get_lock (void) { ACE_NO_HEAP_CHECK; - ACE_NEW_RETURN_I (ACE_Log_Msg_Manager::lock_, ACE_Recursive_Thread_Mutex, 0); + ACE_NEW_RETURN_I (ACE_Log_Msg_Manager::lock_, + ACE_Recursive_Thread_Mutex, + 0); // Allocate the ACE_Log_Msg IPC instance. ACE_NEW_RETURN (ACE_Log_Msg_message_queue, ACE_LOG_MSG_IPC_STREAM, 0); @@ -212,7 +214,9 @@ ACE_Log_Msg::instance (void) { ACE_NO_HEAP_CHECK; - ACE_NEW_RETURN_I (tss_log_msg, ACE_Log_Msg, 0); + ACE_NEW_RETURN_I (tss_log_msg, + ACE_Log_Msg, + 0); // Store the dynamically allocated pointer in thread-specific // storage. It gets deleted via the ACE_TSS_cleanup function // when the thread terminates. @@ -232,8 +236,9 @@ ACE_Log_Msg::instance (void) // ACE_Log_Msg_Manager::get_lock() to initialize the message queue, // so instead we do it here. if (ACE_Log_Msg_message_queue == 0) - ACE_NEW_RETURN (ACE_Log_Msg_message_queue, ACE_LOG_MSG_IPC_STREAM, 0); - + ACE_NEW_RETURN (ACE_Log_Msg_message_queue, + ACE_LOG_MSG_IPC_STREAM, + 0); // Singleton implementation. static ACE_Cleanup_Adapter<ACE_Log_Msg> *log_msg = 0; if (log_msg == 0) diff --git a/ace/Module.cpp b/ace/Module.cpp index 9562a09a22c..da64cac7f4f 100644 --- a/ace/Module.cpp +++ b/ace/Module.cpp @@ -84,10 +84,10 @@ ACE_Module<ACE_SYNCH_USE>::link (ACE_Module<ACE_SYNCH_USE> *m) template <ACE_SYNCH_DECL> int ACE_Module<ACE_SYNCH_USE>::open (const ASYS_TCHAR *mod_name, - ACE_Task<ACE_SYNCH_USE> *writer_q, - ACE_Task<ACE_SYNCH_USE> *reader_q, - void *arg, - int flags /* = M_DELETE */) + ACE_Task<ACE_SYNCH_USE> *writer_q, + ACE_Task<ACE_SYNCH_USE> *reader_q, + void *arg, + int flags /* = M_DELETE */) { ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::open"); this->name (mod_name); @@ -102,13 +102,17 @@ ACE_Module<ACE_SYNCH_USE>::open (const ASYS_TCHAR *mod_name, if (writer_q == 0) { - writer_q = new ACE_Thru_Task<ACE_SYNCH_USE>; + ACE_NEW_RETURN (writer_q, + ACE_Thru_Task<ACE_SYNCH_USE>, + -1); ACE_SET_BITS (flags, M_DELETE_WRITER); } if (reader_q == 0) { - reader_q = new ACE_Thru_Task<ACE_SYNCH_USE>; + ACE_NEW_RETURN (reader_q, + ACE_Thru_Task<ACE_SYNCH_USE>, + -1); ACE_SET_BITS (flags, M_DELETE_READER); } @@ -187,7 +191,9 @@ ACE_Module<ACE_SYNCH_USE>::ACE_Module (const ASYS_TCHAR *mod_name, this->q_pair_[1] = 0; if (this->open (mod_name, writer_q, reader_q, args, flags) == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Module"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Module"))); } template <ACE_SYNCH_DECL> int diff --git a/ace/OS.cpp b/ace/OS.cpp index b20051f125d..8754dbc8f60 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1848,9 +1848,9 @@ ACE_TSS_Cleanup::instance (void) // Now, use the Double-Checked Locking pattern to make sure we // only create the ACE_TSS_Cleanup instance once. if (ACE_TSS_Cleanup::instance_ == 0) - { - ACE_NEW_RETURN (ACE_TSS_Cleanup::instance_, ACE_TSS_Cleanup, 0); - } + ACE_NEW_RETURN (ACE_TSS_Cleanup::instance_, + ACE_TSS_Cleanup, + 0); } return ACE_TSS_Cleanup::instance_; @@ -2004,11 +2004,14 @@ ACE_TSS_Cleanup::tss_keys () if (ts_keys == 0) { - ACE_NEW_RETURN (ts_keys, ACE_TSS_Keys, 0); + ACE_NEW_RETURN (ts_keys, + ACE_TSS_Keys, + 0); // Store the dynamically allocated pointer in thread-specific // storage. if (ACE_OS::thr_setspecific (in_use_, - ACE_reinterpret_cast (void *, ts_keys)) == -1) + ACE_reinterpret_cast (void *, + ts_keys)) == -1) { delete ts_keys; return 0; // Major problems, this should *never* happen! @@ -2087,15 +2090,19 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[]) { ACE_NO_HEAP_CHECK; - ACE_NEW_RETURN (ts_storage, void*[ACE_TSS_THREAD_KEYS_MAX], 0); + ACE_NEW_RETURN (ts_storage, + void*[ACE_TSS_THREAD_KEYS_MAX], + 0); // Zero the entire TSS array. Do it manually instead of using - // memset, for optimum speed. Though, memset may be faster :-) + // memset, for optimum speed. Though, memset may be faster + // :-) void **tss_base_p = ts_storage; - for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) - { - *tss_base_p = 0; - } + + for (u_int i = 0; + i < ACE_TSS_THREAD_KEYS_MAX; + ++i) + *tss_base_p++ = 0; } // Store the pointer in thread-specific storage. It gets deleted @@ -4193,7 +4200,9 @@ writev (ACE_HANDLE handle, ACE_WRITEV_TYPE iov[], int n) # if defined (ACE_HAS_ALLOCA) buf = (char *) alloca (length); # else - ACE_NEW_RETURN (buf, char[length], -1); + ACE_NEW_RETURN (buf, + char[length], + -1); # endif /* !defined (ACE_HAS_ALLOCA) */ char *ptr = buf; @@ -4237,7 +4246,9 @@ ACE_TRACE ("readv"); # if defined (ACE_HAS_ALLOCA) buf = (char *) alloca (length); # else - ACE_NEW_RETURN (buf, char[length], -1); + ACE_NEW_RETURN (buf, + char[length], + -1); # endif /* !defined (ACE_HAS_ALLOCA) */ length = ACE_OS::read_n (handle, buf, length); @@ -6277,7 +6288,9 @@ ACE_OS_Object_Manager::instance (void) { ACE_OS_Object_Manager *instance_pointer; - ACE_NEW_RETURN (instance_pointer, ACE_OS_Object_Manager, 0); + ACE_NEW_RETURN (instance_pointer, + ACE_OS_Object_Manager, + 0); ACE_ASSERT (instance_pointer == instance_); instance_pointer->dynamically_allocated_ = 1; @@ -7279,8 +7279,9 @@ private: # if defined (__BORLANDC__) && (__BORLANDC__ <= 0x540) # define ACE_WIN32CALL_RETURN(X,TYPE,FAILVALUE) \ do { \ + TYPE ace_result_; \ TYPE ace_local_result_ = (TYPE) X; \ - TYPE ace_result_ = ace_local_result_; \ + ace_result_ = ace_local_result_; \ if (ace_result_ == FAILVALUE) \ ACE_OS::set_errno_to_last_error (); \ return ace_result_; \ diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index c6f5e15b430..9ce357842aa 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -235,15 +235,16 @@ ACE_Object_Manager::init (void) ACE_TSS_Emulation::tss_open (ts_storage_); # endif /* ACE_HAS_TSS_EMULATION */ - ACE_NEW_RETURN (preallocations_, ACE_Object_Manager_Preallocations, + ACE_NEW_RETURN (preallocations_, + ACE_Object_Manager_Preallocations, -1); - // Open the main thread's ACE_Log_Msg. (void) ACE_LOG_MSG; } - ACE_NEW_RETURN (default_mask_, ACE_Sig_Set (1), -1); - + ACE_NEW_RETURN (default_mask_, + ACE_Sig_Set (1), + -1); // Finally, indicate that the ACE_Object_Manager instance has // been initialized. object_manager_state_ = OBJ_MAN_INITIALIZED; @@ -301,7 +302,9 @@ ACE_Object_Manager::instance (void) { ACE_Object_Manager *instance_pointer; - ACE_NEW_RETURN (instance_pointer, ACE_Object_Manager, 0); + ACE_NEW_RETURN (instance_pointer, + ACE_Object_Manager, + 0); ACE_ASSERT (instance_pointer == instance_); instance_pointer->dynamically_allocated_ = 1; @@ -309,9 +312,7 @@ ACE_Object_Manager::instance (void) return instance_pointer; } else - { - return instance_; - } + return instance_; } ACE_Sig_Set & @@ -401,41 +402,40 @@ ACE_Object_Manager::get_singleton_lock (ACE_Thread_Mutex *&lock) { if (lock == 0) { - if (starting_up () || shutting_down ()) - { - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - - ACE_NEW_RETURN (lock, ACE_Thread_Mutex, -1); - } - else + if (starting_up () || shutting_down ()) + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + ACE_NEW_RETURN (lock, + ACE_Thread_Mutex, + -1); + } + else + { + // Allocate a new lock, but use double-checked locking to + // ensure that only one thread allocates it. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + *ACE_Object_Manager::instance ()-> + internal_lock_, + -1)); + + if (lock == 0) { - // Allocate a new lock, but use double-checked locking to - // ensure that only one thread allocates it. - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, - ace_mon, - *ACE_Object_Manager::instance ()-> - internal_lock_, - -1)); - - if (lock == 0) - { - ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter; - ACE_NEW_RETURN (lock_adapter, - ACE_Cleanup_Adapter<ACE_Thread_Mutex>, - -1); - lock = &lock_adapter->object (); + ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter; + ACE_NEW_RETURN (lock_adapter, + ACE_Cleanup_Adapter<ACE_Thread_Mutex>, + -1); + lock = &lock_adapter->object (); - // Register the lock for destruction at program - // termination. This call will cause us to grab the - // ACE_Object_Manager::instance ()->internal_lock_ - // again; that's why it is a recursive lock. - ACE_Object_Manager::at_exit (lock_adapter); - } + // Register the lock for destruction at program + // termination. This call will cause us to grab the + // ACE_Object_Manager::instance ()->internal_lock_ + // again; that's why it is a recursive lock. + ACE_Object_Manager::at_exit (lock_adapter); } } @@ -448,16 +448,16 @@ ACE_Object_Manager::get_singleton_lock (ACE_Mutex *&lock) if (lock == 0) { if (starting_up () || shutting_down ()) - { - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - - ACE_NEW_RETURN (lock, ACE_Mutex, -1); - } + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + + ACE_NEW_RETURN (lock, + ACE_Mutex, + -1); else { // Allocate a new lock, but use double-checked locking to @@ -529,17 +529,17 @@ ACE_Object_Manager::get_singleton_lock (ACE_RW_Thread_Mutex *&lock) { if (lock == 0) { - if (starting_up () || shutting_down ()) - { - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - - ACE_NEW_RETURN (lock, ACE_RW_Thread_Mutex, -1); - } + if (starting_up () || shutting_down ()) + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + + ACE_NEW_RETURN (lock, + ACE_RW_Thread_Mutex, + -1); else { // Allocate a new lock, but use double-checked locking to @@ -547,7 +547,7 @@ ACE_Object_Manager::get_singleton_lock (ACE_RW_Thread_Mutex *&lock) ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, *ACE_Object_Manager::instance ()-> - internal_lock_, + internal_lock_, -1)); if (lock == 0) diff --git a/ace/POSIX_Proactor.cpp b/ace/POSIX_Proactor.cpp index 9738b4f1c1a..9a6eb50e940 100644 --- a/ace/POSIX_Proactor.cpp +++ b/ace/POSIX_Proactor.cpp @@ -357,8 +357,6 @@ ACE_POSIX_Proactor::post_wakeup_completions (int how_many) return 0; } -// ********************************************************************* - class ACE_Export ACE_AIOCB_Notify_Pipe_Manager : public ACE_Handler { // = TITLE @@ -913,7 +911,9 @@ ACE_Asynch_Read_Stream_Impl * ACE_POSIX_SIG_Proactor::create_asynch_read_stream (void) { ACE_Asynch_Read_Stream_Impl *implementation = 0; - ACE_NEW_RETURN (implementation, ACE_POSIX_SIG_Asynch_Read_Stream (this), 0); + ACE_NEW_RETURN (implementation, + ACE_POSIX_SIG_Asynch_Read_Stream (this), + 0); return implementation; } @@ -921,7 +921,9 @@ ACE_Asynch_Write_Stream_Impl * ACE_POSIX_SIG_Proactor::create_asynch_write_stream (void) { ACE_Asynch_Write_Stream_Impl *implementation = 0; - ACE_NEW_RETURN (implementation, ACE_POSIX_SIG_Asynch_Write_Stream (this), 0); + ACE_NEW_RETURN (implementation, + ACE_POSIX_SIG_Asynch_Write_Stream (this), + 0); return implementation; } @@ -929,7 +931,9 @@ ACE_Asynch_Read_File_Impl * ACE_POSIX_SIG_Proactor::create_asynch_read_file (void) { ACE_Asynch_Read_File_Impl *implementation = 0; - ACE_NEW_RETURN (implementation, ACE_POSIX_SIG_Asynch_Read_File (this), 0); + ACE_NEW_RETURN (implementation, + ACE_POSIX_SIG_Asynch_Read_File (this), + 0); return implementation; } @@ -937,7 +941,9 @@ ACE_Asynch_Write_File_Impl * ACE_POSIX_SIG_Proactor::create_asynch_write_file (void) { ACE_Asynch_Write_File_Impl *implementation = 0; - ACE_NEW_RETURN (implementation, ACE_POSIX_SIG_Asynch_Write_File (this), 0); + ACE_NEW_RETURN (implementation, + ACE_POSIX_SIG_Asynch_Write_File (this), + 0); return implementation; } @@ -945,7 +951,9 @@ ACE_Asynch_Accept_Impl * ACE_POSIX_SIG_Proactor::create_asynch_accept (void) { ACE_Asynch_Accept_Impl *implementation = 0; - ACE_NEW_RETURN (implementation, ACE_POSIX_SIG_Asynch_Accept (this), 0); + ACE_NEW_RETURN (implementation, + ACE_POSIX_SIG_Asynch_Accept (this), + 0); return implementation; } diff --git a/ace/Priority_Reactor.cpp b/ace/Priority_Reactor.cpp index 6ce6b11ffc8..de12d4b755e 100644 --- a/ace/Priority_Reactor.cpp +++ b/ace/Priority_Reactor.cpp @@ -35,13 +35,13 @@ ACE_Priority_Reactor::init_bucket (void) TUPLE_ALLOCATOR (ACE_Select_Reactor::DEFAULT_SIZE)); // The event handlers are assigned to a new As the Event - ACE_NEW (this->bucket_, QUEUE*[npriorities]); + ACE_NEW (this->bucket_, + QUEUE *[npriorities]); + // This loops "ensures" exception safety. - int i; - for (i = 0; i < npriorities; ++i) - { - ACE_NEW (this->bucket_[i], QUEUE (this->tuple_allocator_)); - } + for (int i = 0; i < npriorities; ++i) + ACE_NEW (this->bucket_[i], + QUEUE (this->tuple_allocator_)); } ACE_Priority_Reactor::ACE_Priority_Reactor (ACE_Sig_Handler *sh, @@ -69,10 +69,10 @@ ACE_Priority_Reactor::ACE_Priority_Reactor (size_t size, ACE_Priority_Reactor::~ACE_Priority_Reactor (void) { ACE_TRACE ("ACE_Priority_Reactor::~ACE_Priority_Reactor"); + for (int i = 0; i < npriorities; ++i) - { - delete this->bucket_[i]; - } + delete this->bucket_[i]; + delete[] this->bucket_; delete tuple_allocator_; } @@ -88,49 +88,37 @@ ACE_Priority_Reactor::dispatch_io_set (int number_of_active_handles, ACE_TRACE ("ACE_Priority_Reactor::dispatch_io_set"); if (number_of_active_handles == 0) - { - return 0; - } - - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("ACE_Priority_Reactor::dispatch_io_set\n"))); - - ACE_HANDLE handle; - + return 0; // The range for which there exists any Event_Tuple is computed on - // the ordering loop, minimizing iterations on the dispatching - // loop. + // the ordering loop, minimizing iterations on the dispatching loop. int min_priority = ACE_Event_Handler::HI_PRIORITY; int max_priority = ACE_Event_Handler::LO_PRIORITY; ACE_Handle_Set_Iterator handle_iter (dispatch_mask); - while ((handle = handle_iter ()) != ACE_INVALID_HANDLE) + for (ACE_HANDLE handle; + (handle = handle_iter ()) != ACE_INVALID_HANDLE; + ) { - ACE_Event_Tuple et (this->handler_rep_.find (handle), handle); + ACE_Event_Tuple et (this->handler_rep_.find (handle), + handle); int prio = et.event_handler_->priority (); // If the priority is out of range assign the minimum priority. if (prio < ACE_Event_Handler::LO_PRIORITY || prio > ACE_Event_Handler::HI_PRIORITY) - { - prio = ACE_Event_Handler::LO_PRIORITY; - } + prio = ACE_Event_Handler::LO_PRIORITY; bucket_[prio]->enqueue_tail (et); + // Update the priority ranges.... if (min_priority > prio) - { - min_priority = prio; - } + min_priority = prio; if (max_priority < prio) - { - max_priority = prio; - } + max_priority = prio; } - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("dispatching.... %d\n"), number_of_active_handles)); - for (int i = max_priority; i >= min_priority; --i) { // Remove all the entries from the wrappers @@ -153,9 +141,7 @@ ACE_Priority_Reactor::dispatch_io_set (int number_of_active_handles, } if (number_dispatched > 0 && this->state_changed_) - { - return -1; - } + return -1; return 0; } diff --git a/ace/Proactor.cpp b/ace/Proactor.cpp index 48700ed4d3c..96a982d9b3e 100644 --- a/ace/Proactor.cpp +++ b/ace/Proactor.cpp @@ -250,15 +250,19 @@ ACE_Proactor::ACE_Proactor (ACE_Proactor_Impl *implementation, #if defined (ACE_HAS_AIO_CALLS) // POSIX Proactor. #if defined (ACE_POSIX_AIOCB_PROACTOR) - ACE_NEW (implementation, ACE_POSIX_AIOCB_Proactor); + ACE_NEW (implementation, + ACE_POSIX_AIOCB_Proactor); #elif defined (ACE_POSIX_SIG_PROACTOR) - ACE_NEW (implementation, ACE_POSIX_SIG_Proactor); + ACE_NEW (implementation, + ACE_POSIX_SIG_Proactor); #else /* Default is to use the SIG one */ - ACE_NEW (implementation, ACE_POSIX_SIG_Proactor); + ACE_NEW (implementation, + ACE_POSIX_SIG_Proactor); #endif #elif (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) // WIN_Proactor. - ACE_NEW (implementation, ACE_WIN32_Proactor); + ACE_NEW (implementation, + ACE_WIN32_Proactor); #endif /* ACE_HAS_AIO_CALLS */ this->implementation (implementation); this->delete_implementation_ = 1; @@ -680,7 +684,8 @@ ACE_Proactor::timer_queue (TIMER_QUEUE *tq) // New timer queue. if (tq == 0) { - this->timer_queue_ = new TIMER_HEAP; + ACE_NEW (this->timer_queue_, + TIMER_HEAP); this->delete_timer_queue_ = 1; } else diff --git a/ace/Process.cpp b/ace/Process.cpp index d560a9d51e8..b4a90c62f8e 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -239,13 +239,16 @@ ACE_Process_Options::ACE_Process_Options (int ie, command_line_argv_calculated_ (0), command_line_buf_ (0) { - ACE_NEW (command_line_buf_, TCHAR[cobl]); + ACE_NEW (command_line_buf_, + TCHAR[cobl]); command_line_buf_[0] = '\0'; #if !defined (ACE_HAS_WINCE) working_directory_[0] = '\0'; - ACE_NEW (environment_buf_, TCHAR[ebl]); - ACE_NEW (environment_argv_, LPTSTR[mea]); + ACE_NEW (environment_buf_, + TCHAR[ebl]); + ACE_NEW (environment_argv_, + LPTSTR[mea]); environment_buf_[0] = '\0'; environment_argv_[0] = 0; diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index d1d3f0ada79..6be9d9b4c4c 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -55,7 +55,9 @@ ACE_Process_Manager::resize (size_t size) ACE_Process_Descriptor *temp; - ACE_NEW_RETURN (temp, ACE_Process_Descriptor[size], -1); + ACE_NEW_RETURN (temp, + ACE_Process_Descriptor[size], + -1); for (size_t i = 0; i < this->max_table_size_; i++) temp[i] = this->proc_table_[i]; // Structure assignment. diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp index 251f5c563e3..0a0b0e073d4 100644 --- a/ace/RB_Tree.cpp +++ b/ace/RB_Tree.cpp @@ -17,11 +17,6 @@ ACE_RCSID(ace, RB_Tree, "$Id$") -///////////////////////////////////////////////////// -// template class ACE_RB_Tree_Node<EXT_ID, INT_ID> // -///////////////////////////////////////////////////// - - // Constructor. template <class EXT_ID, class INT_ID> @@ -40,7 +35,7 @@ ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_I // Destructor. template <class EXT_ID, class INT_ID> -ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node () +ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node (void) { ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node"); @@ -51,12 +46,6 @@ ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node () delete right_; } - - -//////////////////////////////////////////////// -// template class ACE_RB_Tree<EXT_ID, INT_ID> // -//////////////////////////////////////////////// - // Constructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> @@ -71,7 +60,6 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (ACE_Allocator ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_RB_Tree::ACE_RB_Tree\n"))); } - // Copy constructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> @@ -86,10 +74,10 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (const ACE_RB_T // Make a deep copy of the passed tree. ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> iter(rbt); + for (iter.first (); iter.is_done () == 0; iter.next ()) - { - insert_i (*(iter.key ()), *(iter.item ())); - } + insert_i (*(iter.key ()), + *(iter.item ())); } // Destructor. @@ -99,12 +87,11 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree () { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree"); - // Use the locked public method, to be totally safe, as the - // class can be used with an allocator and placement new. + // Use the locked public method, to be totally safe, as the class + // can be used with an allocator and placement new. this->close (); } - // Assignment operator. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void @@ -118,17 +105,17 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator = (const ACE_RB_Tr // Make a deep copy of the passed tree. ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> iter(rbt); + for (iter.first (); iter.is_done () == 0; iter.next ()) - { - insert_i (*(iter.key ()), *(iter.item ())); - } + insert_i (*(iter.key ()), + *(iter.item ())); // Use the same allocator as the rhs. allocator_ = rbt.allocator_; } -// Less than comparison function for keys, default -// functor implementation returns 1 if k1 < k2, 0 otherwise. +// Less than comparison function for keys, default functor +// implementation returns 1 if k1 < k2, 0 otherwise. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::lessthan (const EXT_ID &k1, const EXT_ID &k2) @@ -137,7 +124,6 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::lessthan (const EXT_ID &k1, return this->compare_keys_ (k1, k2); } - // Method for right rotation of the tree about a given node. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void @@ -146,48 +132,37 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_right (ACE_RB_Tre ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_right"); if (! x) - { - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nerror: x is a null pointer in " - "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_right\n"))); - } + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nerror: x is a null pointer in " + "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_right\n"))); else if (! (x->left())) - { - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nerror: x->left () is a null pointer in " "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_right\n"))); - } else - { - ACE_RB_Tree_Node<EXT_ID, INT_ID> * y; - y = x->left (); - x->left (y->right ()); - if (y->right ()) - { - y->right ()->parent (x); - } - y->parent (x->parent ()); - if (x->parent ()) { - if (x == x->parent ()->right ()) - { - x->parent ()->right (y); - } + ACE_RB_Tree_Node<EXT_ID, INT_ID> * y; + y = x->left (); + x->left (y->right ()); + if (y->right ()) + y->right ()->parent (x); + y->parent (x->parent ()); + if (x->parent ()) + { + if (x == x->parent ()->right ()) + x->parent ()->right (y); + else + x->parent ()->left (y); + } else - { - x->parent ()->left (y); - } + root_ = y; + y->right (x); + x->parent (y); } - else - { - root_ = y; - } - y->right (x); - x->parent (y); - } } - // Method for left rotation of the tree about a given node. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void @@ -196,48 +171,37 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_left (ACE_RB_Tree ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rotate_left"); if (! x) - { - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nerror: x is a null pointer in " "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_left\n"))); - } else if (! (x->right())) - { - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nerror: x->right () is a null pointer " "in ACE_RB_Tree<EXT_ID, INT_ID>::RB_rotate_left\n"))); - } else - { - ACE_RB_Tree_Node<EXT_ID, INT_ID> * y; - y = x->right (); - x->right (y->left ()); - if (y->left ()) - { - y->left ()->parent (x); - } - y->parent (x->parent ()); - if (x->parent ()) { - if (x == x->parent ()->left ()) - { - x->parent ()->left (y); - } + ACE_RB_Tree_Node<EXT_ID, INT_ID> * y; + y = x->right (); + x->right (y->left ()); + if (y->left ()) + y->left ()->parent (x); + y->parent (x->parent ()); + if (x->parent ()) + { + if (x == x->parent ()->left ()) + x->parent ()->left (y); + else + x->parent ()->right (y); + } else - { - x->parent ()->right (y); - } - } - else - { - root_ = y; + root_ = y; + y->left (x); + x->parent (y); } - y->left (x); - x->parent (y); - } } - // Method for restoring Red-Black properties after deletion. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void @@ -245,120 +209,107 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tre { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup"); - while (x && - x->parent () && - x->color () == ACE_RB_Tree_Node_Base::BLACK) - { - if (x == x->parent ()->left ()) + while (x + && x->parent () + && x->color () == ACE_RB_Tree_Node_Base::BLACK) { - ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = x->parent ()->right (); - if (w && w->color () == ACE_RB_Tree_Node_Base::RED) - { - w->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->color (ACE_RB_Tree_Node_Base::RED); - RB_rotate_left (x->parent ()); - w = x->parent ()->right (); - } - // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if ((w) && - (!w->left () || - w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) && - (!w->right () || - w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) - { - w->color (ACE_RB_Tree_Node_Base::RED); - x = x->parent (); - } - else - { - // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if (w && - (!w->right () || - w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) + if (x == x->parent ()->left ()) { - if (w->left ()) + ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = x->parent ()->right (); + if (w && w->color () == ACE_RB_Tree_Node_Base::RED) + { + w->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->color (ACE_RB_Tree_Node_Base::RED); + RB_rotate_left (x->parent ()); + w = x->parent ()->right (); + } + // CLR pp. 263 says that nil nodes are implicitly colored BLACK + if ((w) && + (!w->left () + || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) + && (!w->right () + || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) + { + w->color (ACE_RB_Tree_Node_Base::RED); + x = x->parent (); + } + else { - w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + // CLR pp. 263 says that nil nodes are implicitly colored BLACK + if (w && + (!w->right () + || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) + { + if (w->left ()) + w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + w->color (ACE_RB_Tree_Node_Base::RED); + RB_rotate_right (w); + w = x->parent ()->right (); + } + if (w) + { + w->color (x->parent ()->color ()); + if (w->right ()) + w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); + } + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + RB_rotate_left (x->parent ()); + x = root_; } - w->color (ACE_RB_Tree_Node_Base::RED); - RB_rotate_right (w); - w = x->parent ()->right (); } - if (w) - { - w->color (x->parent ()->color ()); - if (w->right ()) - { - w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); - } - } - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - RB_rotate_left (x->parent ()); - x = root_; - } - } - else - { - ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = x->parent ()->left (); - if (w && w->color () == ACE_RB_Tree_Node_Base::RED) - { - w->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->color (ACE_RB_Tree_Node_Base::RED); - RB_rotate_right (x->parent ()); - w = x->parent ()->left (); - } - // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if (w && - (!w->left () || - w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) && - (!w->right () || - w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) - { - w->color (ACE_RB_Tree_Node_Base::RED); - x = x->parent (); - } else - { - // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if (w && - (!w->left () || - w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { - w->color (ACE_RB_Tree_Node_Base::RED); - if (w->right ()) + ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = x->parent ()->left (); + if (w && w->color () == ACE_RB_Tree_Node_Base::RED) + { + w->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->color (ACE_RB_Tree_Node_Base::RED); + RB_rotate_right (x->parent ()); + w = x->parent ()->left (); + } + // CLR pp. 263 says that nil nodes are implicitly colored BLACK + if (w && + (!w->left () + || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) + && (!w->right () + || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { - w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); + w->color (ACE_RB_Tree_Node_Base::RED); + x = x->parent (); + } + else + { + // CLR pp. 263 says that nil nodes are implicitly colored BLACK + if (w && + (!w->left () + || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)) + { + w->color (ACE_RB_Tree_Node_Base::RED); + if (w->right ()) + w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); + RB_rotate_left (w); + w = x->parent ()->left (); + } + if (w) + { + w->color (x->parent ()->color ()); + if (w->left ()) + w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + } + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + RB_rotate_right (x->parent ()); + x = root_; } - RB_rotate_left (w); - w = x->parent ()->left (); } - if (w) - { - w->color (x->parent ()->color ()); - if (w->left ()) - { - w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); - } - } - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - RB_rotate_right (x->parent ()); - x = root_; - } } - } if (x) - { x->color (ACE_RB_Tree_Node_Base::BLACK); - } } - - -// Return a pointer to a matching node if there is one, -// a pointer to the node under which to insert the item -// if the tree is not empty and there is no such match, -// or 0 if the tree is empty. +// Return a pointer to a matching node if there is one, a pointer to +// the node under which to insert the item if the tree is not empty +// and there is no such match, or 0 if the tree is empty. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> * ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_node (const EXT_ID &k, ACE_RB_Tree_Base::RB_SearchResult &result) @@ -369,52 +320,47 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_node (const EXT_ID &k, ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = root_; while (current) - { - // While there are more nodes to examine. - if (this->lessthan (current->key (), k)) - { - // If the search key is greater than the current node's key. - if (current->right ()) - { - // If the right subtree is not empty, search to the right. - current = current->right (); - } - else - { - // If the right subtree is empty, we're done searching, - // and are positioned to the left of the insertion point. - result = LEFT; - break; - } - } - else if (this->lessthan (k, current->key ())) { - // Else if the search key is less than the current node's key. - if (current->left ()) - { - // If the left subtree is not empty, search to the left. - current = current->left (); - } + // While there are more nodes to examine. + if (this->lessthan (current->key (), k)) + { + // If the search key is greater than the current node's key. + if (current->right ()) + // If the right subtree is not empty, search to the right. + current = current->right (); + else + { + // If the right subtree is empty, we're done searching, + // and are positioned to the left of the insertion point. + result = LEFT; + break; + } + } + else if (this->lessthan (k, current->key ())) + { + // Else if the search key is less than the current node's key. + if (current->left ()) + // If the left subtree is not empty, search to the left. + current = current->left (); + else + { + // If the left subtree is empty, we're done searching, + // and are positioned to the right of the insertion point. + result = RIGHT; + break; + } + } else - { - // If the left subtree is empty, we're done searching, - // and are positioned to the right of the insertion point. - result = RIGHT; - break; - } - } - else - { - // If the keys match exactly, we're done as well. - result = EXACT; - break; + { + // If the keys match exactly, we're done as well. + result = EXACT; + break; + } } - } return current; } - // Rebalance the tree after insertion of a node. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void @@ -425,74 +371,74 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rebalance (ACE_RB_Tree_N ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = 0; while (x && - x->parent () && - x->parent ()->color () == ACE_RB_Tree_Node_Base::RED) - { - if (! x->parent ()->parent ()) - { - // If we got here, something is drastically wrong! - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nerror: parent's parent is null in " - "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rebalance\n"))); - return; - } - - if (x->parent () == x->parent ()->parent ()->left ()) + x->parent () + && x->parent ()->color () == ACE_RB_Tree_Node_Base::RED) { - y = x->parent ()->parent ()->right (); - if (y && y->color () == ACE_RB_Tree_Node_Base::RED) - { - // Handle case 1 (see CLR book, pp. 269). - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - y->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); - x = x->parent ()->parent (); - } - else - { - if (x == x->parent ()->right ()) + if (! x->parent ()->parent ()) { - // Transform case 2 into case 3 (see CLR book, pp. 269). - x = x->parent (); - RB_rotate_left (x); + // If we got here, something is drastically wrong! + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nerror: parent's parent is null in " + "ACE_RB_Tree<EXT_ID, INT_ID>::RB_rebalance\n"))); + return; } - // Handle case 3 (see CLR book, pp. 269). - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); - RB_rotate_right (x->parent ()->parent ()); - } - } - else - { - y = x->parent ()->parent ()->left (); - if (y && y->color () == ACE_RB_Tree_Node_Base::RED) - { - // Handle case 1 (see CLR book, pp. 269). - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - y->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); - x = x->parent ()->parent (); - } + if (x->parent () == x->parent ()->parent ()->left ()) + { + y = x->parent ()->parent ()->right (); + if (y && y->color () == ACE_RB_Tree_Node_Base::RED) + { + // Handle case 1 (see CLR book, pp. 269). + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + y->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); + x = x->parent ()->parent (); + } + else + { + if (x == x->parent ()->right ()) + { + // Transform case 2 into case 3 (see CLR book, pp. 269). + x = x->parent (); + RB_rotate_left (x); + } + + // Handle case 3 (see CLR book, pp. 269). + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); + RB_rotate_right (x->parent ()->parent ()); + } + } else - { - if (x == x->parent ()->left ()) { - // Transform case 2 into case 3 (see CLR book, pp. 269). - x = x->parent (); - RB_rotate_right (x); + y = x->parent ()->parent ()->left (); + if (y && y->color () == ACE_RB_Tree_Node_Base::RED) + { + // Handle case 1 (see CLR book, pp. 269). + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + y->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); + x = x->parent ()->parent (); + } + else + { + if (x == x->parent ()->left ()) + { + // Transform case 2 into case 3 (see CLR book, pp. 269). + x = x->parent (); + RB_rotate_right (x); + } + + // Handle case 3 (see CLR book, pp. 269). + x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); + x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); + RB_rotate_left (x->parent ()->parent ()); + } } - - // Handle case 3 (see CLR book, pp. 269). - x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - x->parent ()->parent ()->color (ACE_RB_Tree_Node_Base::RED); - RB_rotate_left (x->parent ()->parent ()); - } } - } } - // Method to find the successor node of the given node in the tree. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> * @@ -501,21 +447,18 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_successor (ACE_RB_T ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_successor"); if (x->right ()) - { return RB_tree_minimum (x->right ()); - } ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = x->parent (); while ((y) && (x == y->right ())) - { - x = y; - y = y->parent (); - } + { + x = y; + y = y->parent (); + } return y; } - // Method to find the predecessor node of the given node in the tree. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> * @@ -524,21 +467,19 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_predecessor (ACE_RB ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_predecessor"); if (x->left ()) - { return RB_tree_maximum (x->left ()); - } ACE_RB_Tree_Node<EXT_ID, INT_ID> *y = x->parent (); + while ((y) && (x == y->left ())) - { - x = y; - y = y->parent (); - } + { + x = y; + y = y->parent (); + } return y; } - // Method to find the minimum node of the subtree rooted at the given node. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> * @@ -547,14 +488,11 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_minimum (ACE_RB_Tre ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_minimum"); while ((x) && (x->left ())) - { x = x->left (); - } return x; } - // Method to find the maximum node of the subtree rooted at the given node. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<EXT_ID, INT_ID> * @@ -563,18 +501,15 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_maximum (ACE_RB_Tre ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_tree_maximum"); while ((x) && (x->right ())) - { x = x->right (); - } return x; } -// Close down an RB_Tree. this method should -// only be called with locks already held. +// Close down an RB_Tree. this method should only be called with +// locks already held. -template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> -int +template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i () { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i"); @@ -586,9 +521,9 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i () return 0; } -// Returns a pointer to the item corresponding to the given key, -// or 0 if it cannot find the key in the tree. This method should -// only be called with locks already held. +// Returns a pointer to the item corresponding to the given key, or 0 +// if it cannot find the key in the tree. This method should only be +// called with locks already held. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_i (const EXT_ID &k, @@ -601,30 +536,26 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find_i (const EXT_ID &k, ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result); if (current && result == EXACT) - { - // Found an exact match: return a pointer to the node. - entry = current; - return 0; - } + { + // Found an exact match: return a pointer to the node. + entry = current; + return 0; + } else - { // The node is not there. return -1; - } } - -// Inserts a *copy* of the key and the item into the tree: -// both the key type EXT_ID and the item type INT_ID must have well -// defined semantics for copy construction and < comparison. -// This method returns a pointer to the inserted item copy, -// or 0 if an error occurred. NOTE: if an identical key -// already exists in the tree, no new item is created, and -// the returned pointer addresses the existing item -// associated with the existing key. This method should +// Inserts a *copy* of the key and the item into the tree: both the +// key type EXT_ID and the item type INT_ID must have well defined +// semantics for copy construction and < comparison. This method +// returns a pointer to the inserted item copy, or 0 if an error +// occurred. NOTE: if an identical key already exists in the tree, no +// new item is created, and the returned pointer addresses the +// existing item associated with the existing key. This method should // only be called with locks already held. -template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> INT_ID* +template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> INT_ID * ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t) { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t)"); @@ -633,116 +564,105 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, RB_SearchResult result = LEFT; ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result); if (current) - { - // If the keys match, just return a pointer to the node's item. - if (result == EXACT) - { - return &(current->item ()); - } - // Otherwise if we're to the left of the insertion - // point, insert into the right subtree. - else if (result == LEFT) { - if (current->right ()) - { - // If there is already a right subtree, complain. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nright subtree already present in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); - } - else - { - // The right subtree is empty: insert new node there. - current->right (new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t)); - if (current->right ()) + // If the keys match, just return a pointer to the node's item. + if (result == EXACT) + return ¤t->item (); + + // Otherwise if we're to the left of the insertion point, insert + // into the right subtree. + else if (result == LEFT) { - // If the node was successfully inserted, set its parent, rebalance - // the tree, color the root black, and return a pointer to the - // inserted item. - INT_ID *item = &(current->right ()->item ()); - current->right ()->parent (current); - RB_rebalance (current->right ()); - root_->color (ACE_RB_Tree_Node_Base::BLACK); - ++current_size_; - return item; + if (current->right ()) + // If there is already a right subtree, complain. + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nright subtree already present in " + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), + 0); + else + { + // The right subtree is empty: insert new node there. + ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; + + ACE_NEW_RETURN (tmp, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + 0); + current->right (tmp); + + // If the node was successfully inserted, set its + // parent, rebalance the tree, color the root black, and + // return a pointer to the inserted item. + INT_ID *item = &(current->right ()->item ()); + current->right ()->parent (current); + RB_rebalance (current->right ()); + root_->color (ACE_RB_Tree_Node_Base::BLACK); + ++current_size_; + return item; + } } - else + // Otherwise, we're to the right of the insertion point, so + // insert into the left subtree. + else // (result == RIGHT) { - // Memory allocation failed. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to current->right_ failed " - "in ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); + if (current->left ()) + // If there is already a left subtree, complain. + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nleft subtree already present in " + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), + 0); + else + { + // The left subtree is empty: insert new node there. + ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + 0); + current->left (tmp); + + // If the node was successfully inserted, set its + // parent, rebalance the tree, color the root black, and + // return a pointer to the inserted item. + INT_ID *item = ¤t->left ()->item (); + current->left ()->parent (current); + RB_rebalance (current->left ()); + root_->color (ACE_RB_Tree_Node_Base::BLACK); + ++current_size_; + return item; + } } - } } - // Otherwise, we're to the right of the insertion - // point, so insert into the left subtree. - else // (result == RIGHT) + else { - if (current->left ()) - { - // If there is already a left subtree, complain. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nleft subtree already present in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); - } - else - { - // The left subtree is empty: insert new node there. - current->left (new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t)); - if (current->left ()) + // The tree is empty: insert at the root and color the root + // black. + ACE_NEW_RETURN (ACE_root_, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + 0); + if (root_) { - // If the node was successfully inserted, set its parent, rebalance - // the tree, color the root black, and return a pointer to the - // inserted item. - INT_ID *item = &(current->left ()->item ()); - current->left ()->parent (current); - RB_rebalance (current->left ()); root_->color (ACE_RB_Tree_Node_Base::BLACK); ++current_size_; - return item; + return &root_->item (); } - else - { - // Memory allocation failed. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to current->left_ failed in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); - } - } - } - } - else - { - // The tree is empty: insert at the root and color the root black. - root_ = new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t); - if (root_) - { - root_->color (ACE_RB_Tree_Node_Base::BLACK); - ++current_size_; - return &(root_->item ()); - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to root_ failed in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); } - } + return 0; } - // Inserts a *copy* of the key and the item into the tree: both the -// key type EXT_ID and the item type INT_ID must have well defined semantics -// for copy construction. The default implementation also requires that -// the key type support well defined < semantics. This method passes back -// a pointer to the inserted (or existing) node, and the search status. If -// the node already exists, the method returns 1. If the node does not -// exist, and a new one is successfully created, and the method returns 0. -// If there was an error, the method returns -1. +// key type EXT_ID and the item type INT_ID must have well defined +// semantics for copy construction. The default implementation also +// requires that the key type support well defined < semantics. This +// method passes back a pointer to the inserted (or existing) node, +// and the search status. If the node already exists, the method +// returns 1. If the node does not exist, and a new one is +// successfully created, and the method returns 0. If there was an +// error, the method returns -1. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int -ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t, +ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, + const INT_ID &t, ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry) { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, const INT_ID &t, " @@ -752,112 +672,96 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, RB_SearchResult result = LEFT; ACE_RB_Tree_Node<EXT_ID, INT_ID> *current = find_node (k, result); if (current) - { - // If the keys match, just return a pointer to the node's item. - if (result == EXACT) - { - entry = current; - return 1; - } - // Otherwise if we're to the left of the insertion - // point, insert into the right subtree. - else if (result == LEFT) { - if (current->right ()) - { - // If there is already a right subtree, complain. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nright subtree already present in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); - } - else - { - // The right subtree is empty: insert new node there. - current->right (new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t)); - if (current->right ()) + // If the keys match, just return a pointer to the node's item. + if (result == EXACT) { - // If the node was successfully inserted, set its parent, rebalance - // the tree, color the root black, and return a pointer to the - // inserted item. - entry = current->right (); - current->right ()->parent (current); - RB_rebalance (current->right ()); - root_->color (ACE_RB_Tree_Node_Base::BLACK); - ++current_size_; - return 0; + entry = current; + return 1; } - else + // Otherwise if we're to the left of the insertion + // point, insert into the right subtree. + else if (result == LEFT) { - // Memory allocation failed. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to current->right_ failed " - "in ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); - } - } - } - // Otherwise, we're to the right of the insertion - // point, so insert into the left subtree. - else // (result == RIGHT) - { - if (current->left ()) - { - // If there is already a left subtree, complain. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nleft subtree already present in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); - } - else - { - // The left subtree is empty: insert new node there. - current->left (new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t)); - if (current->left ()) - { - // If the node was successfully inserted, set its parent, rebalance - // the tree, color the root black, and return a pointer to the - // inserted item. - entry = current->left (); - current->left ()->parent (current); - RB_rebalance (current->left ()); - root_->color (ACE_RB_Tree_Node_Base::BLACK); - ++current_size_; - return 0; + if (current->right ()) + { + // If there is already a right subtree, complain. + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nright subtree already present in " + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), + -1); + } + else + { + // The right subtree is empty: insert new node there. + ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + -1); + current->right (tmp); + + // If the node was successfully inserted, set its parent, rebalance + // the tree, color the root black, and return a pointer to the + // inserted item. + entry = current->right (); + current->right ()->parent (current); + RB_rebalance (current->right ()); + root_->color (ACE_RB_Tree_Node_Base::BLACK); + ++current_size_; + return 0; + } } - else + // Otherwise, we're to the right of the insertion point, so + // insert into the left subtree. + else // (result == RIGHT) { - // Memory allocation failed. - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to current->left_ failed in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); + if (current->left ()) + // If there is already a left subtree, complain. + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("\nleft subtree already present in " + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), + -1); + else + { + // The left subtree is empty: insert new node there. + ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + -1); + current->left (tmp); + // If the node was successfully inserted, set its + // parent, rebalance the tree, color the root black, and + // return a pointer to the inserted item. + entry = current->left (); + current->left ()->parent (current); + RB_rebalance (current->left ()); + root_->color (ACE_RB_Tree_Node_Base::BLACK); + ++current_size_; + return 0; + } } - } } - } else - { - // The tree is empty: insert at the root and color the root black. - root_ = new ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t); - if (root_) { + // The tree is empty: insert at the root and color the root black. + ACE_NEW_RETURN (root_, + ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + -1); root_->color (ACE_RB_Tree_Node_Base::BLACK); ++current_size_; entry = root_; return 0; } - else - { - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nmemory allocation to root_ failed in " - "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); - } - } + return -1; } - -// Removes the item associated with the given key from the -// tree and destroys it. Returns 1 if it found the item -// and successfully destroyed it, 0 if it did not find the -// item, or -1 if an error occurred. This method should -// only be called with locks already held. +// Removes the item associated with the given key from the tree and +// destroys it. Returns 1 if it found the item and successfully +// destroyed it, 0 if it did not find the item, or -1 if an error +// occurred. This method should only be called with locks already +// held. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (const EXT_ID &k, INT_ID &i) @@ -874,7 +778,7 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (const EXT_ID &k, { // Return the internal id stored in the deleted node. i = z->item (); - return (-1 == this->remove_i (z)) ? -1 : 1; + return -1 == this->remove_i (z) ? -1 : 1; } else { @@ -888,56 +792,45 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node< { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)"); - // Delete the node and reorganize the tree to satisfy the Red-Black properties. + // Delete the node and reorganize the tree to satisfy the Red-Black + // properties. ACE_RB_Tree_Node<EXT_ID, INT_ID> *x, *y; - if ((z->left ()) && (z->right ())) - { + if (z->left () && z->right ()) y = RB_tree_successor (z); - } else - { y = z; - } + if (y->left ()) - { x = y->left (); - } else - { x = y->right (); - } + if (x) - { - x->parent (y->parent ()); - } + x->parent (y->parent ()); + if (y->parent ()) - { - if (y == y->parent ()->left ()) { - y->parent ()->left (x); - } - else - { - y->parent ()->right (x); + if (y == y->parent ()->left ()) + y->parent ()->left (x); + else + y->parent ()->right (x); } - } else - { root_ = x; - } + if (y != z) - { - // Copy the elements of y into z. - z->key () = y->key (); - z->item () = y->item (); - } + { + // Copy the elements of y into z. + z->key () = y->key (); + z->item () = y->item (); + } + // CLR pp. 263 says that nil nodes are implicitly colored BLACK if (!y || y->color () == ACE_RB_Tree_Node_Base::BLACK) - { RB_delete_fixup (x); - } + y->parent (0); y->right (0); y->left (0); @@ -947,13 +840,6 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node< return 0; } - - -/////////////////////////////////////////////////////////////////////// -// template class // -// ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> // -/////////////////////////////////////////////////////////////////////// - ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator_Base) // Constructor. @@ -966,13 +852,9 @@ ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_I // Position the iterator at the first (or last) node in the tree. if (set_first) - { - node_ = tree_->RB_tree_minimum (tree_->root_); - } + node_ = tree_->RB_tree_minimum (tree_->root_); else - { - node_ = tree_->RB_tree_maximum (tree_->root_); - } + node_ = tree_->RB_tree_maximum (tree_->root_); } // Copy constructor. @@ -995,7 +877,6 @@ ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator= (co node_ = iter.node_; } - // Destructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> @@ -1004,12 +885,6 @@ ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_ ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator_Base"); } - -////////////////////////////////////////////////////////////////// -// template class // -// ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> // -////////////////////////////////////////////////////////////////// - ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator) // Constructor. @@ -1022,7 +897,6 @@ ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterat ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator"); } - // Destructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> @@ -1031,11 +905,6 @@ ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Itera ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator"); } -////////////////////////////////////////////////////////////////////////// -// template class // -// ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> // -////////////////////////////////////////////////////////////////////////// - ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Reverse_Iterator) // Constructor. @@ -1047,7 +916,6 @@ ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tre ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator"); } - // Destructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> @@ -1056,5 +924,4 @@ ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tr ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Reverse_Iterator"); } - #endif /* !defined (ACE_RB_TREE_C) */ diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index bb43fcbdee8..ebf860d9786 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -35,15 +35,19 @@ ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl, || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \ || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) #if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) - ACE_NEW (impl, ACE_TP_Reactor); + ACE_NEW (impl, + ACE_TP_Reactor); #else - ACE_NEW (impl, ACE_Select_Reactor); + ACE_NEW (impl, + ACE_Select_Reactor); #endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */ #else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */ #if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL) - ACE_NEW (impl, ACE_Msg_WFMO_Reactor); + ACE_NEW (impl, + ACE_Msg_WFMO_Reactor); #else - ACE_NEW (impl, ACE_WFMO_Reactor); + ACE_NEW (impl, + ACE_WFMO_Reactor); #endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */ #endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */ this->implementation (impl); @@ -80,7 +84,9 @@ ACE_Reactor::instance (void) if (ACE_Reactor::reactor_ == 0) { - ACE_NEW_RETURN (ACE_Reactor::reactor_, ACE_Reactor, 0); + ACE_NEW_RETURN (ACE_Reactor::reactor_, + ACE_Reactor, + 0); ACE_Reactor::delete_reactor_ = 1; } } diff --git a/ace/Remote_Tokens.cpp b/ace/Remote_Tokens.cpp index 72881602d7d..7e47be74ac0 100644 --- a/ace/Remote_Tokens.cpp +++ b/ace/Remote_Tokens.cpp @@ -58,7 +58,9 @@ ACE_TSS_Connection::make_TSS_TYPE (void) const ACE_SOCK_Connector connector; ACE_SOCK_Stream *stream = 0; - ACE_NEW_RETURN (stream, ACE_SOCK_Stream, 0); + ACE_NEW_RETURN (stream, + ACE_SOCK_Stream, + 0); if (connector.connect (*stream, server_address_) == -1) { diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index 7c25da9af3e..1e780337673 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -283,7 +283,9 @@ ACE_SOCK_Dgram::send (const iovec iov[], #if defined (ACE_HAS_ALLOCA) buf = alloca (length); #else - ACE_NEW_RETURN (buf, char[length], -1); + ACE_NEW_RETURN (buf, + char[length], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ char *ptr = buf; @@ -330,7 +332,9 @@ ACE_SOCK_Dgram::recv (iovec iov[], #if defined (ACE_HAS_ALLOCA) buf = alloca (length); #else - ACE_NEW_RETURN (buf, char[length], -1); + ACE_NEW_RETURN (buf, + char[length], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ length = ACE_SOCK_Dgram::recv (buf, length, addr, flags); diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp index abf00af3559..2431033c70d 100644 --- a/ace/SOCK_IO.cpp +++ b/ace/SOCK_IO.cpp @@ -94,7 +94,9 @@ ACE_SOCK_IO::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -132,7 +134,9 @@ ACE_SOCK_IO::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); diff --git a/ace/SPIPE_Stream.cpp b/ace/SPIPE_Stream.cpp index 29a5433dd3d..533a47bf080 100644 --- a/ace/SPIPE_Stream.cpp +++ b/ace/SPIPE_Stream.cpp @@ -40,7 +40,9 @@ ACE_SPIPE_Stream::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -75,7 +77,9 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else - ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); diff --git a/ace/SString.cpp b/ace/SString.cpp index ce850e4673f..84d12bedf9a 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -646,7 +646,9 @@ ACE_WString::char_rep (void) const { char *t; - ACE_NEW_RETURN (t, char[this->len_ + 1], 0); + ACE_NEW_RETURN (t, + char[this->len_ + 1], + 0); for (size_t i = 0; i < this->len_; i++) // Note that this cast may lose data if wide chars are diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 8ddf2e566f5..52a2ec4b190 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -73,8 +73,9 @@ ACE_STATIC_SVCS * ACE_Service_Config::static_svcs (void) { if (ACE_Service_Config::static_svcs_ == 0) - ACE_NEW_RETURN (ACE_Service_Config::static_svcs_, ACE_STATIC_SVCS, 0); - + ACE_NEW_RETURN (ACE_Service_Config::static_svcs_, + ACE_STATIC_SVCS, + 0); return ACE_Service_Config::static_svcs_; } @@ -514,11 +515,12 @@ ACE_Service_Config::load_static_svcs (void) ACE_Service_Type *sr; - ACE_NEW_RETURN (sr, ACE_Service_Type (ssd->name_, - stp, - 0, - ssd->active_), -1); - + ACE_NEW_RETURN (sr, + ACE_Service_Type (ssd->name_, + stp, + 0, + ssd->active_), + -1); if (ACE_Service_Repository::instance ()->insert (sr) == -1) return -1; } diff --git a/ace/Signal.cpp b/ace/Signal.cpp index 16fd4fef9f5..a596ba17a33 100644 --- a/ace/Signal.cpp +++ b/ace/Signal.cpp @@ -465,8 +465,9 @@ ACE_Sig_Handlers_Set::instance (int signum) if (signum <= 0 || signum >= ACE_NSIG) return 0; // This will cause problems... else if (ACE_Sig_Handlers_Set::sig_handlers_[signum] == 0) - ACE_NEW_RETURN (ACE_Sig_Handlers_Set::sig_handlers_[signum], ACE_SIG_HANDLERS_SET, 0); - + ACE_NEW_RETURN (ACE_Sig_Handlers_Set::sig_handlers_[signum], + ACE_SIG_HANDLERS_SET, + 0); return ACE_Sig_Handlers_Set::sig_handlers_[signum]; } @@ -527,8 +528,10 @@ ACE_Sig_Handlers::register_handler (int signum, // Create a new 3rd party disposition, remembering its // preferred signal blocking etc...; - ACE_NEW_RETURN (extern_sh, ACE_Sig_Adapter (sa, ++ACE_Sig_Handlers::sigkey_), -1); - + ACE_NEW_RETURN (extern_sh, + ACE_Sig_Adapter (sa, + ++ACE_Sig_Handlers::sigkey_), + -1); // Add the external signal handler to the set of handlers // for this signal. if (ACE_Sig_Handlers_Set::instance (signum)->insert (extern_sh) == -1) @@ -538,8 +541,10 @@ ACE_Sig_Handlers::register_handler (int signum, } } // Add our new handler at this point. - ACE_NEW_RETURN (ace_sig_adapter, ACE_Sig_Adapter (new_sh, ++ACE_Sig_Handlers::sigkey_), -1); - + ACE_NEW_RETURN (ace_sig_adapter, + ACE_Sig_Adapter (new_sh, + ++ACE_Sig_Handlers::sigkey_), + -1); // Add the ACE signal handler to the set of handlers for this // signal (make sure it goes before the external one if there is // one of these). @@ -750,7 +755,10 @@ ACE_Sig_Handlers::handler (int signum, ACE_Event_Handler *new_sh) // ACE_Unbounded_Set...). ACE_Sig_Adapter *temp; - ACE_NEW_RETURN (temp, ACE_Sig_Adapter (new_sh, ++ACE_Sig_Handlers::sigkey_), 0); + ACE_NEW_RETURN (temp, + ACE_Sig_Adapter (new_sh, + ++ACE_Sig_Handlers::sigkey_), + 0); handler_set->insert (temp); return *eh; } diff --git a/ace/Singleton.cpp b/ace/Singleton.cpp index 3ebca15eed5..81c64546af6 100644 --- a/ace/Singleton.cpp +++ b/ace/Singleton.cpp @@ -68,8 +68,9 @@ ACE_Singleton<TYPE, ACE_LOCK>::instance (void) // ACE_Object_Manager: we'll have to leak this instance. #endif /* ACE_MT_SAFE */ - ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0); - + ACE_NEW_RETURN (singleton, + (ACE_Singleton<TYPE, + ACE_LOCK>), 0); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) } else @@ -86,8 +87,9 @@ ACE_Singleton<TYPE, ACE_LOCK>::instance (void) if (singleton == 0) { - ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0); - + ACE_NEW_RETURN (singleton, + (ACE_Singleton<TYPE, + ACE_LOCK>), 0); // Register for destruction with ACE_Object_Manager. ACE_Object_Manager::at_exit (singleton); } @@ -159,9 +161,9 @@ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance (void) // don't register for destruction with the // ACE_Object_Manager: we'll have to leak this instance. #endif /* ACE_MT_SAFE */ - - ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>), 0); - + ACE_NEW_RETURN (singleton, + (ACE_TSS_Singleton<TYPE, ACE_LOCK>), + 0); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) } else @@ -177,9 +179,9 @@ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance (void) if (singleton == 0) { - ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>), + ACE_NEW_RETURN (singleton, + (ACE_TSS_Singleton<TYPE, ACE_LOCK>), 0); - // Register for destruction with ACE_Object_Manager. ACE_Object_Manager::at_exit (singleton); } diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index 55898c2ecc8..47a832cbb99 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -77,18 +77,17 @@ ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh) // Create an ACE_Service_Type containing the SVC_Handler and // insert into this->svc_rep_; - ACE_Service_Type_Impl *stp = - new ACE_Service_Object_Type (svc_handler, this->svc_name_); - - if (stp == 0) - { - errno = ENOMEM; - return -1; - } + ACE_Service_Type_Impl *stp; + ACE_NEW_RETURN (stp, + ACE_Service_Object_Type (svc_handler, + this->svc_name_), + -1); ACE_Service_Type *srp = - new ACE_Service_Type (this->svc_name_, stp, handle, 1); - + new ACE_Service_Type (this->svc_name_, + stp, + handle, + 1); if (srp == 0) { delete stp; diff --git a/ace/Stream.cpp b/ace/Stream.cpp index f8af657ff6d..efdffd1cbb0 100644 --- a/ace/Stream.cpp +++ b/ace/Stream.cpp @@ -231,26 +231,10 @@ ACE_Stream<ACE_SYNCH_USE>::push_module (ACE_Module<ACE_SYNCH_USE> *new_top, return 0; } -#if 0 template <ACE_SYNCH_DECL> int ACE_Stream<ACE_SYNCH_USE>::open (void *a, - ACE_Multiplexor &muxer, - ACE_Module<ACE_SYNCH_USE> *head) -{ - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::open"); - this->stream_head_ = head == 0 - ? new ACE_Module<ACE_SYNCH_USE> ("ACE_Stream_Head", - new ACE_Stream_Head<ACE_SYNCH_USE>, - new ACE_Stream_Head<ACE_SYNCH_USE>, a) : head; - this->stream_tail_ = 0; - return muxer.link_from_below (this->stream_head_); -} -#endif - -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::open (void *a, - ACE_Module<ACE_SYNCH_USE> *head, - ACE_Module<ACE_SYNCH_USE> *tail) + ACE_Module<ACE_SYNCH_USE> *head, + ACE_Module<ACE_SYNCH_USE> *tail) { ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::open"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); @@ -355,11 +339,12 @@ ACE_Stream<ACE_SYNCH_USE>::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, ACE_Message_Block *db; // Try to create a data block that contains the user-supplied data. - ACE_NEW_RETURN (db, ACE_Message_Block (sizeof (int), - ACE_Message_Block::MB_IOCTL, - 0, - (char *) a), -1); - + ACE_NEW_RETURN (db, + ACE_Message_Block (sizeof (int), + ACE_Message_Block::MB_IOCTL, + 0, + (char *) a), + -1); // Try to create a control block <cb> that contains the control // field and a pointer to the data block <db> in <cb>'s continuation // field. diff --git a/ace/Synch_T.cpp b/ace/Synch_T.cpp index 5946d443182..2c75b420838 100644 --- a/ace/Synch_T.cpp +++ b/ace/Synch_T.cpp @@ -32,7 +32,8 @@ ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::ACE_Lock_Adapter (void) : lock_ (0), delete_lock_ (1) { - ACE_NEW (this->lock_, ACE_LOCKING_MECHANISM); + ACE_NEW (this->lock_, + ACE_LOCKING_MECHANISM); } template <class ACE_LOCKING_MECHANISM> @@ -725,7 +726,9 @@ ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (ACE_LOCK &lock, int block) this->init_key (); ACE_Guard<ACE_LOCK> *guard; - ACE_NEW (guard, ACE_Guard<ACE_LOCK> (lock, block)); + ACE_NEW (guard, + ACE_Guard<ACE_LOCK> (lock, + block)); #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter; @@ -788,7 +791,9 @@ ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard (ACE_LOCK &lock, this->init_key (); ACE_Guard<ACE_LOCK> *guard; - ACE_NEW (guard, ACE_Write_Guard<ACE_LOCK> (lock, block)); + ACE_NEW (guard, + ACE_Write_Guard<ACE_LOCK> (lock, + block)); #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter; @@ -873,8 +878,9 @@ ACE_TSS_Read_Guard<ACE_LOCK>::ACE_TSS_Read_Guard (ACE_LOCK &lock, int block) this->init_key (); ACE_Guard<ACE_LOCK> *guard; - ACE_NEW (guard, ACE_Read_Guard<ACE_LOCK> (lock, block)); - + ACE_NEW (guard, + ACE_Read_Guard<ACE_LOCK> (lock, + block)); #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter; ACE_NEW (tss_adapter, diff --git a/ace/System_Time.cpp b/ace/System_Time.cpp index 0ad522daca9..833086650cd 100644 --- a/ace/System_Time.cpp +++ b/ace/System_Time.cpp @@ -10,7 +10,8 @@ ACE_System_Time::ACE_System_Time (LPCTSTR poolname) : delta_time_ (0) { ACE_TRACE ("ACE_System_Time::ACE_System_Time"); - ACE_NEW (this->shmem_, ALLOCATOR (poolname)); + ACE_NEW (this->shmem_, + ALLOCATOR (poolname)); } ACE_System_Time::~ACE_System_Time (void) diff --git a/ace/TLI.cpp b/ace/TLI.cpp index f6d0ec697cc..39b17f2a58d 100644 --- a/ace/TLI.cpp +++ b/ace/TLI.cpp @@ -27,7 +27,8 @@ ACE_TLI::ACE_TLI (void) // (jph@ccrl.nj.nec.com) for the help. this->so_opt_req.opt.maxlen = sizeof (opthdr) + sizeof (long); - ACE_NEW (this->so_opt_req.opt.buf, char[this->so_opt_req.opt.maxlen]); + ACE_NEW (this->so_opt_req.opt.buf, + char[this->so_opt_req.opt.maxlen]); this->so_opt_ret.opt.maxlen = sizeof (opthdr) + sizeof (long); this->so_opt_ret.opt.buf = new char[this->so_opt_ret.opt.maxlen]; diff --git a/ace/Task_T.cpp b/ace/Task_T.cpp index b6425369a05..17c4612e67e 100644 --- a/ace/Task_T.cpp +++ b/ace/Task_T.cpp @@ -56,7 +56,8 @@ ACE_Task<ACE_SYNCH_USE>::ACE_Task (ACE_Thread_Manager *thr_man, if (mq == 0) { - ACE_NEW (mq, ACE_Message_Queue<ACE_SYNCH_USE>); + ACE_NEW (mq, + ACE_Message_Queue<ACE_SYNCH_USE>); this->delete_msg_queue_ = 1; } diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index b4210955aa6..560cf96f404 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -203,7 +203,11 @@ ACE_Thread_Descriptor::at_exit (void *object, else { ACE_At_Thread_Exit* cleanup; - ACE_NEW_RETURN (cleanup, ACE_At_Thread_Exit_Func (object,cleanup_hook,param), -1); + ACE_NEW_RETURN (cleanup, + ACE_At_Thread_Exit_Func (object, + cleanup_hook, + param), + -1); this->at_push (cleanup); } #endif /* ACE_USE_ONE_SHOT_AT_THREAD_EXIT */ @@ -240,7 +244,8 @@ ACE_Thread_Descriptor::ACE_Thread_Descriptor (void) this->cleanup_info_.object_ = 0; this->cleanup_info_.param_ = 0; #endif /* ACE_USE_ONE_SHOT_AT_THREAD_EXIT */ - ACE_NEW (this->sync_, ACE_DEFAULT_THREAD_MANAGER_LOCK); + ACE_NEW (this->sync_, + ACE_DEFAULT_THREAD_MANAGER_LOCK); } void @@ -334,7 +339,9 @@ ACE_Thread_Manager::instance (void) if (ACE_Thread_Manager::thr_mgr_ == 0) { - ACE_NEW_RETURN (ACE_Thread_Manager::thr_mgr_, ACE_Thread_Manager, 0); + ACE_NEW_RETURN (ACE_Thread_Manager::thr_mgr_, + ACE_Thread_Manager, + 0); ACE_Thread_Manager::delete_thr_mgr_ = 1; } } @@ -443,13 +450,19 @@ ACE_Thread_Exit::instance (void) if (instance_ == 0) { - ACE_NEW_RETURN (instance_, ACE_TSS_TYPE (ACE_Thread_Exit), 0); + ACE_NEW_RETURN (instance_, + ACE_TSS_TYPE (ACE_Thread_Exit), + 0); // Register for destruction with ACE_Object_Manager. #if defined ACE_HAS_SIG_C_FUNC - ACE_Object_Manager::at_exit (instance_, ACE_Thread_Exit_cleanup, 0); + ACE_Object_Manager::at_exit (instance_, + ACE_Thread_Exit_cleanup, + 0); #else - ACE_Object_Manager::at_exit (instance_, ACE_Thread_Exit::cleanup, 0); + ACE_Object_Manager::at_exit (instance_, + ACE_Thread_Exit::cleanup, + 0); #endif /* ACE_HAS_SIG_C_FUNC */ } } @@ -660,7 +673,9 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, if (t_id == 0) { char *thr_id; - ACE_NEW_RETURN (thr_id, char[16], -1); + ACE_NEW_RETURN (thr_id, + char[16], + -1); // Mark the thread ID to show that the ACE_Thread_Manager // allocated it. thr_id[0] = ACE_THR_ID_ALLOCATED; @@ -842,7 +857,9 @@ ACE_Thread_Manager::append_thr (ACE_thread_t t_id, ACE_Thread_Descriptor *thr_desc; if (td == 0) - ACE_NEW_RETURN (thr_desc, ACE_Thread_Descriptor, -1); + ACE_NEW_RETURN (thr_desc, + ACE_Thread_Descriptor, + -1); else thr_desc = td; diff --git a/ace/Timer_Hash_T.cpp b/ace/Timer_Hash_T.cpp index d6d8e2b3921..66a4f26031d 100644 --- a/ace/Timer_Hash_T.cpp +++ b/ace/Timer_Hash_T.cpp @@ -56,14 +56,16 @@ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::timeout (ACE_Timer_Queue_T<ACE_E { ACE_UNUSED_ARG (timer_queue); - Hash_Token *h = (Hash_Token *)arg; - - int ret = this->timer_hash_->upcall_functor ().timeout (*this->timer_hash_, - handler, - h->act_, - cur_time); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + ACE_const_cast (void *, + arg)); + int result = + this->timer_hash_->upcall_functor ().timeout (*this->timer_hash_, + handler, + h->act_, + cur_time); delete h; - return ret; + return result; } @@ -85,20 +87,22 @@ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::cancellation (ACE_Timer_Queue_T< template <class TYPE, class FUNCTOR, class ACE_LOCK> int ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::deletion (ACE_Timer_Queue_T<ACE_Event_Handler *, - ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, - ACE_Null_Mutex> &timer_queue, - ACE_Event_Handler *handler, - const void *arg) + ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, + ACE_Null_Mutex> &timer_queue, + ACE_Event_Handler *handler, + const void *arg) { ACE_UNUSED_ARG (timer_queue); - Hash_Token *h = (Hash_Token *)arg; - - int ret = this->timer_hash_->upcall_functor ().deletion (*this->timer_hash_, - handler, - h->act_); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + ACE_const_cast (void *, + arg)); + int result = + this->timer_hash_->upcall_functor ().deletion (*this->timer_hash_, + handler, + h->act_); delete h; - return ret; + return result; } @@ -107,7 +111,7 @@ template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &hash) : timer_hash_ (hash) { - this->first(); + this->first (); // Nothing } @@ -133,7 +137,6 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::first (void) this->iter_ = 0; } - // Positions the iterator at the next node in the bucket or goes to the next // bucket @@ -164,7 +167,6 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void) this->iter_->next (); } - // Returns true when we are at the end (when bucket_item_ == 0) template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int @@ -173,7 +175,6 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::isdone (void) return this->iter_ == 0; } - // Returns the node at the current position in the sequence template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> * @@ -211,11 +212,14 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (size_t tabl for (size_t i = 0; i < table_size; i++) { - this->table_[i] = new BUCKET (&this->table_functor_, this->free_list_); + ACE_NEW (this->table_[i], + BUCKET (&this->table_functor_, + this->free_list_)); this->table_[i]->gettimeofday (ACE_OS::gettimeofday); } - iterator_ = new HASH_ITERATOR(*this); + ACE_NEW (iterator_, + HASH_ITERATOR (*this)); } @@ -235,11 +239,14 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (FUNCTOR *up for (size_t i = 0; i < this->table_size_; i++) { - this->table_[i] = new BUCKET (&this->table_functor_, this->free_list_); + ACE_NEW (this->table_[i], + BUCKET (&this->table_functor_, + this->free_list_)); this->table_[i]->gettimeofday (ACE_OS::gettimeofday); } - iterator_ = new HASH_ITERATOR(*this); + ACE_NEW (iterator_, + HASH_ITERATOR (*this)); } @@ -268,7 +275,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::is_empty (void) const return this->table_[this->earliest_position_]->is_empty (); } - // Returns earliest time in a non-empty bucket template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> const ACE_Time_Value & @@ -292,7 +298,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } - // Reschedule a periodic timer. This function must be called with the // mutex lock held. @@ -301,9 +306,12 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (ACE_Timer_Node_T< { ACE_TRACE ("ACE_Timer_Hash_T::reschedule"); - size_t position = expired->get_timer_value ().usec () % this->table_size_; + size_t position = + expired->get_timer_value ().usec () % this->table_size_; - Hash_Token *h = (Hash_Token *)expired->get_act (); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + ACE_const_cast (void *, + expired->get_act ())); h->orig_id_ = this->table_[position]->schedule (expired->get_type (), h, @@ -311,11 +319,11 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (ACE_Timer_Node_T< expired->get_interval ()); if (this->table_[this->earliest_position_]->is_empty () - || this->table_[position]->earliest_time () < this->table_[this->earliest_position_]->earliest_time ()) + || this->table_[position]->earliest_time () + < this->table_[this->earliest_position_]->earliest_time ()) this->earliest_position_ = position; } - // Insert a new handler that expires at time future_time; if interval // is > 0, the handler will be reinvoked periodically. @@ -330,7 +338,13 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type, size_t position = future_time.usec () % this->table_size_; - Hash_Token *h = new Hash_Token (act, position, 0); + Hash_Token *h; + + ACE_NEW_RETURN (h, + Hash_Token (act, + position, + 0), + -1); h->orig_id_ = this->table_[position]->schedule (type, h, @@ -343,7 +357,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type, ++this->size_; - return (long) h; + return ACE_reinterpret_cast (long, + h); } // Locate and remove the single <ACE_Event_Handler> with a value of @@ -351,20 +366,23 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type, template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id, - const void **act, - int dont_call) + const void **act, + int dont_call) { ACE_TRACE ("ACE_Timer_Hash_T::cancel"); ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); // Make sure we are getting a valid <timer_id>, not an error - // returned by schedule () + // returned by <schedule>. if (timer_id == -1) return 0; - Hash_Token *h = (Hash_Token *)timer_id; + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + timer_id); - int ret = this->table_[h->pos_]->cancel (h->orig_id_, act, dont_call); + int result = this->table_[h->pos_]->cancel (h->orig_id_, + act, + dont_call); if (h->pos_ == this->earliest_position_) this->find_new_earliest (); @@ -376,10 +394,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id, --this->size_; - return ret; + return result; } - // Locate and remove all values of <type> from the timer queue. template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int @@ -392,18 +409,29 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type, size_t i; // loop variable - Hash_Token **timer_ids = new Hash_Token *[this->size_]; + Hash_Token **timer_ids; + + ACE_NEW_RETURN (timer_ids, + Hash_Token *[this->size_], + -1); size_t pos = 0; - for (i = 0; i < this->table_size_; i++) + for (i = 0; + i < this->table_size_; + i++) { - ACE_Timer_Queue_Iterator_T<TYPE, ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, ACE_Null_Mutex> &iter = this->table_[i]->iter (); - for (iter.first (); !iter.isdone (); iter.next ()) + ACE_Timer_Queue_Iterator_T<TYPE, ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, ACE_Null_Mutex> &iter = + this->table_[i]->iter (); + + for (iter.first (); + !iter.isdone (); + iter.next ()) if (iter.item ()->get_type () == type) timer_ids[pos++] = (Hash_Token *)iter.item ()->get_act (); } - ACE_ASSERT (pos <= this->size_); + if (pos <= this->size_) + return -1; for (i = 0; i < pos; i++) { @@ -417,14 +445,13 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type, delete [] timer_ids; if (dont_call == 0) - this->upcall_functor ().cancellation (*this, type); + this->upcall_functor ().cancellation (*this, type); this->find_new_earliest (); return pos; } - // Removes the earliest node and finds the new earliest position template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> * @@ -433,7 +460,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::remove_first (void) if (this->is_empty ()) return 0; - ACE_Timer_Node_T<TYPE> *temp = this->table_[this->earliest_position_]->remove_first (); + ACE_Timer_Node_T<TYPE> *temp = + this->table_[this->earliest_position_]->remove_first (); this->find_new_earliest (); @@ -449,13 +477,12 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::find_new_earliest (void) { for (size_t i = 0; i < this->table_size_; i++) if (!this->table_[i]->is_empty ()) - if (this->table_[this->earliest_position_]->is_empty() + if (this->table_[this->earliest_position_]->is_empty () || this->earliest_time () == ACE_Time_Value::zero || this->table_[i]->earliest_time () <= this->earliest_time ()) this->earliest_position_ = i; } - // Returns the earliest node without removing it template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> * @@ -469,7 +496,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::get_first (void) return this->table_[this->earliest_position_]->get_first (); } - // Dummy version of expire to get rid of warnings in Sun CC 4.2 template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int @@ -478,7 +504,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire () return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire(); } - // Specialized expire for Timer Hash template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int @@ -493,10 +518,12 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value // Go through the table and expire anything that can be expired - for (size_t i = 0; i < this->table_size_; i++) + for (size_t i = 0; + i < this->table_size_; + i++) { - while (!this->table_[i]->is_empty () && - this->table_[i]->earliest_time () <= cur_time) + while (!this->table_[i]->is_empty () + && this->table_[i]->earliest_time () <= cur_time) { expired = this->table_[i]->remove_first (); --this->size_; @@ -510,18 +537,23 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value // Make sure that we skip past values that have already // "expired". do - expired->set_timer_value (expired->get_timer_value () + expired->get_interval ()); + expired->set_timer_value (expired->get_timer_value () + + expired->get_interval ()); while (expired->get_timer_value () <= cur_time); - // Since this is an interval timer, we need to reschedule - // it. + // Since this is an interval timer, we need to + // reschedule it. this->reschedule (expired); reclaim = 0; } // call the functor - Hash_Token *h = (Hash_Token *)act; - this->upcall (type, h->act_, cur_time); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + ACE_const_cast (void *, + act)); + this->upcall (type, + h->act_, + cur_time); if (reclaim) { diff --git a/ace/Timer_Heap_T.cpp b/ace/Timer_Heap_T.cpp index b67e0bc5f6f..0389707a459 100644 --- a/ace/Timer_Heap_T.cpp +++ b/ace/Timer_Heap_T.cpp @@ -89,7 +89,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (size_t size, // Create the heap array. ACE_NEW (this->heap_, - (ACE_Timer_Node_T<TYPE> *[size])); + ACE_Timer_Node_T<TYPE> *[size]); // Create the parallel ACE_NEW (this->timer_ids_, @@ -104,7 +104,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (size_t size, if (preallocate) { ACE_NEW (this->preallocated_nodes_, - (ACE_Timer_Node_T<TYPE>[size])); + ACE_Timer_Node_T<TYPE>[size]); // Add allocated array to set of such arrays for deletion // on cleanup. @@ -140,10 +140,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (FUNCTOR *upcall_fun // Create the heap array. #if defined (__IBMCPP__) && (__IBMCPP__ >= 400) ACE_NEW (this->heap_, - (ACE_Timer_Node_T<TYPE> *[ACE_DEFAULT_TIMERS])); + ACE_Timer_Node_T<TYPE> *[ACE_DEFAULT_TIMERS]); #else ACE_NEW (this->heap_, - (ACE_Timer_Node_T<TYPE> *[this->max_size_])); + ACE_Timer_Node_T<TYPE> *[this->max_size_]); #endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */ // Create the parallel array. @@ -410,14 +410,14 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void) #if defined (__IBMCPP__) && (__IBMCPP__ >= 400) ACE_NEW (new_heap, - (ACE_Timer_Node_T<TYPE> *[1024])); + ACE_Timer_Node_T<TYPE> *[1024]); #else ACE_NEW (new_heap, - (ACE_Timer_Node_T<TYPE> *[new_size])); + ACE_Timer_Node_T<TYPE> *[new_size]); #endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */ ACE_NEW (new_heap, - (ACE_Timer_Node_T<TYPE> *[new_size])); + ACE_Timer_Node_T<TYPE> *[new_size]); ACE_OS::memcpy (new_heap, this->heap_, max_size_ * sizeof *new_heap); @@ -449,10 +449,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void) // to existing list. #if defined (__IBMCPP__) && (__IBMCPP__ >= 400) ACE_NEW (this->preallocated_nodes_, - (ACE_Timer_Node_T<TYPE>[88])); + ACE_Timer_Node_T<TYPE>[88]); #else ACE_NEW (this->preallocated_nodes_, - (ACE_Timer_Node_T<TYPE>[this->max_size_])); + ACE_Timer_Node_T<TYPE>[this->max_size_]); #endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */ // Add it to the set for later deletion @@ -517,7 +517,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void) // Only allocate a node if we are *not* using the preallocated heap. if (this->preallocated_nodes_ == 0) ACE_NEW_RETURN (temp, - (ACE_Timer_Node_T<TYPE>), + ACE_Timer_Node_T<TYPE>, 0); else { diff --git a/ace/Timer_List_T.cpp b/ace/Timer_List_T.cpp index 73aba79ea01..2b9176d9589 100644 --- a/ace/Timer_List_T.cpp +++ b/ace/Timer_List_T.cpp @@ -86,7 +86,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_T (FUNCTOR *upcall_fun this->head_->set_next (this->head_); this->head_->set_prev (this->head_); - iterator_ = new LIST_ITERATOR(*this); + ACE_NEW (iterator_, + LIST_ITERATOR (*this)); } @@ -211,7 +212,6 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type, return (long) temp; } - // Locate and remove the single <ACE_Event_Handler> with a value of // <timer_id> from the timer queue. diff --git a/ace/Timer_Wheel_T.cpp b/ace/Timer_Wheel_T.cpp index c654cd7d616..ff1557b2660 100644 --- a/ace/Timer_Wheel_T.cpp +++ b/ace/Timer_Wheel_T.cpp @@ -40,10 +40,11 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void) this->pos_++) { // Skip over empty entries - if (this->timer_wheel_.wheel_[this->pos_]->get_next () != - this->timer_wheel_.wheel_[this->pos_]) + if (this->timer_wheel_.wheel_[this->pos_]->get_next () + != this->timer_wheel_.wheel_[this->pos_]) { - this->list_item_ = this->timer_wheel_.wheel_[this->pos_]->get_next (); + this->list_item_ = + this->timer_wheel_.wheel_[this->pos_]->get_next (); return; } } @@ -52,7 +53,6 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void) this->list_item_ = 0; } - // Positions the iterator at the next node in list or goes to the next // list @@ -62,18 +62,22 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void) if (this->isdone ()) return; - this->list_item_ = this->list_item_->get_next (); + this->list_item_ = + this->list_item_->get_next (); // If there is no more in the current list, go to the next if (this->list_item_ == this->timer_wheel_.wheel_[this->pos_]) { - for (this->pos_++; this->pos_ < this->timer_wheel_.wheel_size_; this->pos_++) + for (this->pos_++; + this->pos_ < this->timer_wheel_.wheel_size_; + this->pos_++) { // Check for an empty entry - if (this->timer_wheel_.wheel_[this->pos_]->get_next () != - this->timer_wheel_.wheel_[this->pos_]) + if (this->timer_wheel_.wheel_[this->pos_]->get_next () + != this->timer_wheel_.wheel_[this->pos_]) { - this->list_item_ = this->timer_wheel_.wheel_[this->pos_]->get_next (); + this->list_item_ = + this->timer_wheel_.wheel_[this->pos_]->get_next (); return; } } @@ -82,7 +86,6 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void) } } - // Returns true when we are at the end (when list_item_ == 0) template <class TYPE, class FUNCTOR, class ACE_LOCK> int @@ -91,7 +94,6 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) return this->list_item_ == 0; } - // Returns the node at the current position in the sequence template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> * @@ -103,9 +105,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void) return this->list_item_; } - -// Constructor that sets up the timing wheel and also may preallocate some -// nodes on the free list +// Constructor that sets up the timing wheel and also may preallocate +// some nodes on the free list template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (size_t wheelsize, @@ -124,13 +125,14 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (size_t wheelsize, this->gettimeofday (ACE_OS::gettimeofday); // Create the timing wheel - ACE_NEW (this->wheel_, (ACE_Timer_Node_T<TYPE> *[wheelsize])); - + ACE_NEW (this->wheel_, + ACE_Timer_Node_T<TYPE> *[wheelsize]); // Create the dummy nodes for (i = 0; i < wheelsize; i++) { - ACE_Timer_Node_T<TYPE> *tempnode = this->alloc_node (); + ACE_Timer_Node_T<TYPE> *tempnode = + this->alloc_node (); tempnode->set_next (tempnode); tempnode->set_prev (tempnode); this->wheel_[i] = tempnode; @@ -139,12 +141,13 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (size_t wheelsize, // Do the preallocation this->free_list_->resize (prealloc); - iterator_ = new WHEEL_ITERATOR(*this); + ACE_NEW (iterator_, + WHEEL_ITERATOR (*this)); } template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (FUNCTOR *upcall_functor, - ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist) + ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist) : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor, freelist), wheel_size_ (ACE_DEFAULT_TIMER_WHEEL_SIZE), resolution_ (ACE_DEFAULT_TIMER_WHEEL_RESOLUTION), @@ -156,7 +159,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (FUNCTOR *upcall_f this->gettimeofday (ACE_OS::gettimeofday); // Create the timing wheel - ACE_NEW (this->wheel_, (ACE_Timer_Node_T<TYPE> *[this->wheel_size_])); + ACE_NEW (this->wheel_, + ACE_Timer_Node_T<TYPE> *[this->wheel_size_]); // Create the dummy nodes for (i = 0; i < this->wheel_size_; i++) @@ -167,7 +171,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (FUNCTOR *upcall_f this->wheel_[i] = tempnode; } - iterator_ = new WHEEL_ITERATOR(*this); + ACE_NEW (iterator_, + WHEEL_ITERATOR (*this)); } // Destructor just cleans up its memory @@ -179,15 +184,20 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T (void) delete iterator_; - for (size_t i = 0; i < this->wheel_size_; i++) + for (size_t i = 0; + i < this->wheel_size_; + i++) { // delete nodes until only the dummy node is left while (this->wheel_[i]->get_next () != this->wheel_[i]) { - ACE_Timer_Node_T<TYPE> *next = this->wheel_[i]->get_next (); + ACE_Timer_Node_T<TYPE> *next = + this->wheel_[i]->get_next (); this->wheel_[i]->set_next (next->get_next ()); next->get_next ()->set_prev (this->wheel_[i]); - this->upcall_functor ().deletion (*this, next->get_type (), next->get_act ()); + this->upcall_functor ().deletion (*this, + next->get_type (), + next->get_act ()); this->free_node (next); } @@ -199,7 +209,6 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T (void) delete [] this->wheel_; } - // Checks to see if <earliest_pos> points to a empty list (then it is empty) template <class TYPE, class FUNCTOR, class ACE_LOCK> int @@ -210,7 +219,6 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const return this->wheel_[this->earliest_pos_]->get_next () == this->wheel_[this->earliest_pos_]; } - // Returns the first (earliest) node in the <wheel_>'s <earliest_pos_> list template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value & @@ -224,8 +232,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const return this->wheel_[this->earliest_pos_]->get_next ()->get_timer_value (); } -// Create the node and pass it to reschedule. Also check to see if the -// <earliest_pos> should be changed. +// Create the node and pass it to reschedule. Also check to see if +// the <earliest_pos> should be changed. template <class TYPE, class FUNCTOR, class ACE_LOCK> long ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type, @@ -262,13 +270,12 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type, return -1; } - // Goes through every list in the wheel and if it finds a node with <type> // then it removes the node and continues on looking for other nodes template <class TYPE, class FUNCTOR, class ACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, - int dont_call_handle_close) + int dont_call_handle_close) { ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); @@ -299,15 +306,14 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, this->free_node (tempnode); } else - { - curr = curr->get_next (); - } + curr = curr->get_next (); } } // Look for a new earliest time - ACE_Time_Value earliest_time; // defaults to zero + // Defaults to zero. + ACE_Time_Value earliest_time; // Check every entry in the table for (i = 0; i < this->wheel_size_; i++) @@ -319,36 +325,37 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, if (earliest_time == ACE_Time_Value::zero || this->wheel_[i]->get_timer_value () < earliest_time) { - earliest_time = this->wheel_[i]->get_next ()->get_timer_value (); + earliest_time = + this->wheel_[i]->get_next ()->get_timer_value (); this->earliest_pos_ = i; } } } if (dont_call_handle_close == 0) - this->upcall_functor ().cancellation (*this, type); - + this->upcall_functor ().cancellation (*this, + type); return number_of_cancellations; } - // Takes the <timer_id> and casts it to a pointer. Then it removes it // from its neighbors template <class TYPE, class FUNCTOR, class ACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id, - const void **act, - int dont_call_handle_close) + const void **act, + int dont_call_handle_close) { ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); // Make sure we are getting a valid <timer_id>, not an error - // returned by schedule () + // returned by <schedule>. if (timer_id == -1) return 0; - ACE_Timer_Node_T<TYPE> *node = (ACE_Timer_Node_T<TYPE> *) timer_id; + ACE_Timer_Node_T<TYPE> *node = + (ACE_Timer_Node_T<TYPE> *) timer_id; // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE> if (timer_id == node->get_timer_id ()) @@ -360,9 +367,10 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id, *act = node->get_act (); if (dont_call_handle_close == 0) - this->upcall_functor ().cancellation (*this, node->get_type ()); + this->upcall_functor ().cancellation (*this, + node->get_type ()); - // Find out what position it is in + // Find out what position it is in. size_t pos = (node->get_timer_value ().usec () / this->resolution_) % this->wheel_size_; this->free_node (node); @@ -383,7 +391,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id, if (earliest_time == ACE_Time_Value::zero || this->wheel_[i]->get_timer_value () < earliest_time) { - earliest_time = this->wheel_[i]->get_next ()->get_timer_value (); + earliest_time = + this->wheel_[i]->get_next ()->get_timer_value (); this->earliest_pos_ = i; } } @@ -397,7 +406,6 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id, return 0; } - // Dumps out some properties of this object template <class TYPE, class FUNCTOR, class ACE_LOCK> void @@ -424,7 +432,6 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } - // Removes the earliest node and then find the new <earliest_pos_> template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> * @@ -433,7 +440,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void) ACE_TRACE ("ACE_Timer_Wheel_T::remove_first"); // Remove the item - ACE_Timer_Node_T<TYPE> *temp = this->wheel_[this->earliest_pos_]->get_next (); + ACE_Timer_Node_T<TYPE> *temp = + this->wheel_[this->earliest_pos_]->get_next (); temp->get_prev ()->set_next (temp->get_next ()); temp->get_next ()->set_prev (temp->get_prev ()); @@ -449,17 +457,16 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void) if (earliest_time == ACE_Time_Value::zero || this->wheel_[i]->get_timer_value () < earliest_time) { - earliest_time = this->wheel_[i]->get_next ()->get_timer_value (); + earliest_time = + this->wheel_[i]->get_next ()->get_timer_value (); this->earliest_pos_ = i; } } } - return temp; } - // Returns the earliest node without removing it template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> * @@ -470,25 +477,26 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void) return this->wheel_[this->earliest_pos_]->get_next (); } - -// Takes an ACE_Timer_Node and inserts it into the correct position in the correct -// list +// Takes an ACE_Timer_Node and inserts it into the correct position in +// the correct list. template <class TYPE, class FUNCTOR, class ACE_LOCK> void ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE> *expired) { ACE_TRACE ("ACE_Timer_Wheel_T::reschedule"); - size_t pos = (expired->get_timer_value ().usec () / this->resolution_) % this->wheel_size_; + size_t pos = + (expired->get_timer_value ().usec () / this->resolution_) % this->wheel_size_; // See if we need to update the earliest time if (this->earliest_time () == ACE_Time_Value::zero || expired->get_timer_value () < this->earliest_time ()) this->earliest_pos_ = pos; - // Insert time into dummy node + // Insert time into dummy node. this->wheel_[pos]->set_timer_value (expired->get_timer_value ()); - ACE_Timer_Node_T<TYPE> *cursor = this->wheel_[pos]->get_next (); + ACE_Timer_Node_T<TYPE> *cursor = + this->wheel_[pos]->get_next (); // Find position to insert while (cursor->get_timer_value () < expired->get_timer_value ()) @@ -501,7 +509,6 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE> * expired->get_prev ()->set_next (expired); } - // Just return the iterator template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> & @@ -519,11 +526,11 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire () return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire (); } - -// Specialized expire which expires in total order. It is optimized by keeping -// track of the list with the earliest element and the next earliest list. It -// then goes through the earliest list until it can switch to the second list. -// it keeps going until it finishes with everything before the <cur_time> +// Specialized expire which expires in total order. It is optimized +// by keeping track of the list with the earliest element and the next +// earliest list. It then goes through the earliest list until it can +// switch to the second list. it keeps going until it finishes with +// everything before the <cur_time> template <class TYPE, class FUNCTOR, class ACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_time) @@ -570,11 +577,14 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_ti } } - while (this->wheel_[earliest]->get_next () != this->wheel_[earliest] - && this->wheel_[earliest]->get_next ()->get_timer_value () <= next_earliest_time) + while (this->wheel_[earliest]->get_next () + != this->wheel_[earliest] + && this->wheel_[earliest]->get_next ()->get_timer_value () + <= next_earliest_time) { // Remove the first node in the earliest position - ACE_Timer_Node_T<TYPE> *expired = this->wheel_[earliest]->get_next (); + ACE_Timer_Node_T<TYPE> *expired = + this->wheel_[earliest]->get_next (); this->wheel_[earliest]->set_next (expired->get_next ()); expired->get_next ()->set_prev (this->wheel_[earliest]); @@ -591,22 +601,22 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_ti expired->set_timer_value (expired->get_timer_value () + expired->get_interval ()); while (expired->get_timer_value () <= cur_time); - // Since this is an interval timer, we need to reschedule - // it. + // Since this is an interval timer, we need to + // reschedule it. this->reschedule (expired); reclaim = 0; } - // call the functor + // Call the functor. this->upcall (type, act, cur_time); if (reclaim) - // Free up the node and the token + // Free up the node and the token. this->free_node (expired); ++number_of_timers_expired; - // Check to see if we are empty + // Check to see if we are empty. if (this->wheel_[earliest]->get_next () == this->wheel_[earliest]) break; } @@ -620,5 +630,4 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_ti return number_of_timers_expired; } - #endif /* ACE_TIMER_WHEEL_T_C */ diff --git a/ace/Token_Invariants.cpp b/ace/Token_Invariants.cpp index cf98e79c21d..19257569899 100644 --- a/ace/Token_Invariants.cpp +++ b/ace/Token_Invariants.cpp @@ -28,8 +28,9 @@ ACE_Token_Invariant_Manager::instance (void) if (instance_ == 0) { - ACE_NEW_RETURN (instance_, ACE_Token_Invariant_Manager, 0); - + ACE_NEW_RETURN (instance_, + ACE_Token_Invariant_Manager, + 0); // Register for destruction with ACE_Object_Manager. ACE_Object_Manager::at_exit (instance_); } @@ -160,8 +161,9 @@ ACE_Token_Invariant_Manager::get_mutex (const char *token_name, { ACE_Mutex_Invariants *new_invariant; - ACE_NEW_RETURN (new_invariant, ACE_Mutex_Invariants, -1); - + ACE_NEW_RETURN (new_invariant, + ACE_Mutex_Invariants, + -1); if (mutex_collection_.bind (name, new_invariant) == -1) { delete new_invariant; @@ -187,8 +189,9 @@ ACE_Token_Invariant_Manager::get_rwlock (const char *token_name, { ACE_RWLock_Invariants *new_invariant; - ACE_NEW_RETURN (new_invariant, ACE_RWLock_Invariants, -1); - + ACE_NEW_RETURN (new_invariant, + ACE_RWLock_Invariants, + -1); if (rwlock_collection_.bind (name, new_invariant) == -1) return -1; diff --git a/ace/Token_Manager.cpp b/ace/Token_Manager.cpp index d202bae2006..6d49239debd 100644 --- a/ace/Token_Manager.cpp +++ b/ace/Token_Manager.cpp @@ -54,8 +54,9 @@ ACE_Token_Manager::instance (void) if (token_manager_ == 0) { - ACE_NEW_RETURN (token_manager_, ACE_Token_Manager, 0); - + ACE_NEW_RETURN (token_manager_, + ACE_Token_Manager, + 0); // Register for destruction with ACE_Object_Manager. ACE_Object_Manager::at_exit (token_manager_); } diff --git a/ace/UPIPE_Stream.cpp b/ace/UPIPE_Stream.cpp index 7cc6f94adf0..494b7c179b3 100644 --- a/ace/UPIPE_Stream.cpp +++ b/ace/UPIPE_Stream.cpp @@ -99,8 +99,9 @@ ACE_UPIPE_Stream::send (const char *buffer, ACE_TRACE ("ACE_UPIPE_Stream::send"); ACE_Message_Block *mb_p; - ACE_NEW_RETURN (mb_p, ACE_Message_Block (n), -1); - + ACE_NEW_RETURN (mb_p, + ACE_Message_Block (n), + -1); mb_p->copy (buffer, n); return this->stream_.put (mb_p, timeout) == -1 ? -1 : (int) n; } diff --git a/ace/WFMO_Reactor.cpp b/ace/WFMO_Reactor.cpp index f30e0545bc5..8b541928394 100644 --- a/ace/WFMO_Reactor.cpp +++ b/ace/WFMO_Reactor.cpp @@ -1042,7 +1042,9 @@ ACE_WFMO_Reactor::open (size_t size, if (tq == 0) { - ACE_NEW_RETURN (this->timer_queue_, ACE_Timer_Heap, -1); + ACE_NEW_RETURN (this->timer_queue_, + ACE_Timer_Heap, + -1); this->delete_timer_queue_ = 1; } else @@ -1057,7 +1059,9 @@ ACE_WFMO_Reactor::open (size_t size, if (sh == 0) { - ACE_NEW_RETURN (this->signal_handler_, ACE_Sig_Handler, -1); + ACE_NEW_RETURN (this->signal_handler_, + ACE_Sig_Handler, + -1); this->delete_signal_handler_ = 1; } else |