int ACE_HTTP_Addr::set (const ACE_TCHAR *host_name, const ACE_TCHAR *path, const ACE_TCHAR *query, u_short port) { if (host_name == 0 || path == 0) return -1; this->clear (); ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (host_name), -1); this->port_number_ = port; ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (path), -1); if (query != 0) ACE_ALLOCATOR_RETURN (this->query_, ACE_OS::strdup (query), -1); else this->query_ = 0; size_t size = this->url_size (1); ACE_TCHAR *buffer; ACE_ALLOCATOR_RETURN (buffer, reinterpret_cast<ACE_TCHAR *> (ACE_OS::malloc (size)), -1); if (this->addr_to_string (buffer, size, 1) == -1) return -1; this->set_url (buffer); return 0; }
int ACE_FTP_Addr::set (const ACE_TCHAR *host_name, const ACE_TCHAR *path, const ACE_TCHAR *user, const ACE_TCHAR *password) { if (host_name == 0 || path == 0) return -1; this->clear (); ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (host_name), -1); ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (path), -1); if (user != 0) ACE_ALLOCATOR_RETURN (this->user_, ACE_OS::strdup (user), -1); else this->user_ = 0; if (this->password_ != 0) ACE_ALLOCATOR_RETURN (this->password_, ACE_OS::strdup (password), -1); else this->password_ = 0; size_t size = this->url_size (1); ACE_TCHAR *buffer; ACE_ALLOCATOR_RETURN (buffer, reinterpret_cast<ACE_TCHAR *> (ACE_OS::malloc (size)), -1); if (this->addr_to_string (buffer, size, 1) == -1) return -1; this->set_url (buffer); return 0; }
int ACE_Mailto_Addr::set (const ACE_TCHAR *user, const ACE_TCHAR *hostname, const ACE_TCHAR *headers) { if (user == 0 || hostname == 0) return -1; this->clear (); ACE_ALLOCATOR_RETURN (this->user_, ACE_OS::strdup (user), -1); ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (hostname), -1); if (headers != 0) ACE_ALLOCATOR_RETURN (this->headers_, ACE_OS::strdup (headers), -1); else this->headers_ = 0; size_t size = this->url_size (1); ACE_TCHAR *buffer; ACE_ALLOCATOR_RETURN (buffer, ACE_reinterpret_cast(ACE_TCHAR *, ACE_OS::malloc (size)), -1); if (this->addr_to_string (buffer, size, 1) == -1) return -1; this->set_url (buffer); return 0; }
int ACE_FTP_Addr::string_to_addr (const ACE_TCHAR *address) { if (address == 0) return -1; if (ACE_OS::strncasecmp (ftp, address, ftp_size) != 0) return -1; this->clear (); this->hostname_ = 0; this->user_ = 0; this->password_ = 0; this->path_ = 0; // Save the original URL.... this->ACE_URL_Addr::string_to_addr (address); const ACE_TCHAR *string = address; string += ftp_size; string += 2; // == strlen ("//"); // Make a copy of the string to manipulate it. ACE_TCHAR *t; ACE_ALLOCATOR_RETURN (t, ACE_OS::strdup (string), -1); ACE_TCHAR *path_start = ACE_OS::strchr (t, '/'); if (path_start != 0) { // terminate the host:port substring path_start[0] = '\0'; path_start++; ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (path_start), -1); } ACE_TCHAR *host_start = ACE_OS::strchr (t, '@'); if (host_start != 0) { host_start[0] = '\0'; host_start++; ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (host_start), -1); ACE_TCHAR *pass_start = ACE_OS::strchr (t, ':'); if (pass_start != 0) { pass_start[0] = '\0'; pass_start++; ACE_ALLOCATOR_RETURN (this->password_, ACE_OS::strdup (pass_start), -1); } this->user_ = t; } else { this->hostname_ = t; } return 0; }
int ACE_HTTP_Addr::string_to_addr (const ACE_TCHAR *address) { if (address == 0) return -1; if (ACE_OS::strncasecmp (http, address, http_size) != 0) return -1; this->clear (); this->hostname_ = 0; this->path_ = 0; this->query_ = 0; // Save the original URL.... if (this->ACE_URL_Addr::string_to_addr (address) != 0) return -1; const ACE_TCHAR *string = address; string += http_size; string += 2; // == strlen ("//"); // Make a copy of the string to manipulate it. ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (string), -1); ACE_TCHAR *path_start = ACE_OS::strchr (this->hostname_, '/'); if (path_start != 0) { // terminate the host:port substring path_start[0] = '\0'; path_start++; ACE_TCHAR *query_start = ACE_OS::strchr (path_start, '?'); if (query_start != 0) { query_start[0] = '\0'; query_start++; ACE_ALLOCATOR_RETURN (this->query_, ACE_OS::strdup (query_start), -1); } ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (path_start), -1); } // By now t is null terminated at the start of the path, find the // port (if present). ACE_TCHAR *port_start = ACE_OS::strchr(this->hostname_, ':'); this->port_number_ = ACE_DEFAULT_HTTP_PORT; if (port_start != 0) { // terminate the ipaddr. port_start[0] = '\0'; port_start++; this->port_number_ = ACE_OS::atoi (port_start); } return 0; }
int ACE_Mailto_Addr::set (const ACE_Mailto_Addr &addr) { if (this->ACE_URL_Addr::set (addr) != 0) return -1; this->clear (); ACE_ALLOCATOR_RETURN (this->user_, ACE_OS::strdup (addr.user_), -1); ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (addr.hostname_), -1); if (addr.headers_ != 0) ACE_ALLOCATOR_RETURN (this->headers_, ACE_OS::strdup (addr.headers_), -1); else this->headers_ = 0; return 0; }
int ACE_Mailto_Addr::string_to_addr (const ACE_TCHAR *address) { if (ACE_OS::strncasecmp (mailto, address, mailto_size) != 0) return -1; this->clear (); this->user_ = 0; this->hostname_ = 0; this->headers_ = 0; // Save the original URL.... if (this->ACE_URL_Addr::string_to_addr (address) != 0) return -1; const ACE_TCHAR *string = address; string += mailto_size; // Make a copy of the string to manipulate it. ACE_TCHAR *t; ACE_ALLOCATOR_RETURN (t, ACE_OS::strdup (string), -1); ACE_TCHAR *host_start = ACE_OS::strchr (t, '@'); if (host_start != 0) { // terminate the host:port substring host_start[0] = '\0'; host_start++; ACE_TCHAR *headers_start = ACE_OS::strchr (host_start, '?'); if (headers_start != 0) { headers_start[0] = '\0'; headers_start++; ACE_ALLOCATOR_RETURN (this->headers_, ACE_OS::strdup (headers_start), -1); } ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (host_start), -1); } else { ACE_OS::free (t); return -1; } this->user_ = t; return 0; }
ACE_UINT16 * ACE_NS_WString::ushort_rep (void) const { ACE_TRACE ("ACE_NS_WString::ushort_rep"); if (this->len_ <= 0) return 0; else { ACE_UINT16 *t = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (t, static_cast<ACE_UINT16*> (ACE_Allocator::instance()->malloc(sizeof(ACE_UINT16) * (this->len_ + 1))), 0); #else ACE_NEW_RETURN (t, ACE_UINT16[this->len_ + 1], 0); #endif for (size_type i = 0; i < this->len_; ++i) // Note that this cast may lose data if wide chars are // actually used! t[i] = (ACE_UINT16)this->rep_[i]; t[this->len_] = 0; return t; } }
static int init_buffer (size_t index) { ACE_INT32 len; if (ACE::recv_n (poll_array[index].fd, (void *) &len, sizeof (ACE_INT32)) != sizeof (ACE_INT32)) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "recv_n failed"), -1); else { len = ntohl (len); ACE_DEBUG ((LM_DEBUG, "(%P|%t) reading messages of size %d from handle %d\n", len, poll_array[index].fd)); ACE_ALLOCATOR_RETURN (buffer_array[index].buf_, ACE_OS::malloc (len), -1); buffer_array[index].len_ = len; } return 0; }
template<class T> int ACE_Array_Base<T>::max_size (size_t new_size) { if (new_size > this->max_size_) { T *tmp = 0; ACE_ALLOCATOR_RETURN (tmp, (T *) this->allocator_->malloc (new_size * sizeof (T)), -1); for (size_t i = 0; i < this->cur_size_; ++i) new (&tmp[i]) T (this->array_[i]); // Initialize the new portion of the array that exceeds the // previously allocated section. for (size_t j = this->cur_size_; j < new_size; j++) new (&tmp[j]) T; ACE_DES_ARRAY_FREE (this->array_, this->max_size_, this->allocator_->free, T); this->array_ = tmp; this->max_size_ = new_size; this->cur_size_ = new_size; } return 0; }
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::trybind_i (const EXT_ID &ext_id, INT_ID &int_id, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry) { size_t loc; int result = this->shared_find (ext_id, entry, loc); if (result == -1) { // Not found. void *ptr; ACE_ALLOCATOR_RETURN (ptr, this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)), -1); entry = new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id, int_id, this->table_[loc].next_, &this->table_[loc]); this->table_[loc].next_ = entry; entry->next_->prev_ = entry; this->cur_size_++; return 0; } else return 1; }
// utility functions void* createIndex(const std::string& tag , PersistenceUpdater::ALLOCATOR& allocator , size_t size, bool& exists) { void* index = 0; // This is the easy case since if we find hash table in the // memory-mapped file we know it's already initialized. if (allocator.find(tag.c_str(), index) == 0) { exists = true; return index; } else { exists = false; ACE_ALLOCATOR_RETURN(index, allocator.malloc(size), 0); if (allocator.bind(tag.c_str(), index) == -1) { allocator.free(index); index = 0; } } return index; }
int ACE_INET_Addr::string_to_addr (const char s[], int address_family) { ACE_TRACE ("ACE_INET_Addr::string_to_addr"); int result; char *ip_buf = 0; char *ip_addr = 0; // Need to make a duplicate since we'll be overwriting the string. ACE_ALLOCATOR_RETURN (ip_buf, ACE_OS::strdup (s), -1); ip_addr = ip_buf; // We use strrchr because of IPv6 addresses. char *port_p = ACE_OS::strrchr (ip_addr, ':'); #if defined (ACE_HAS_IPV6) // Check for extended IPv6 format : '[' <ipv6 address> ']' ':' <port> if (ip_addr[0] == '[') { // find closing bracket char *cp_pos = ACE_OS::strchr (ip_addr, ']'); // check for port separator after closing bracket // if not found leave it, error will come later if (cp_pos) { *cp_pos = '\0'; // blank out ']' ++ip_addr; // skip over '[' if (cp_pos[1] == ':') port_p = cp_pos + 1; else port_p = cp_pos; // leads to error on missing port } } #endif /* ACE_HAS_IPV6 */ if (port_p == 0) // Assume it's a port number. { char *endp = 0; u_short port = static_cast<u_short> (ACE_OS::strtol (ip_addr, &endp, 10)); if (*endp == '\0') // strtol scanned the entire string - all digits result = this->set (port, ACE_UINT32 (INADDR_ANY)); else // port name result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY)); } else { *port_p = '\0'; ++port_p; // skip over ':' char *endp = 0; u_short port = static_cast<u_short> (ACE_OS::strtol (port_p, &endp, 10)); if (*endp == '\0') // strtol scanned the entire string - all digits result = this->set (port, ip_addr, 1, address_family); else result = this->set (port_p, ip_addr); } ACE_OS::free (ACE_MALLOC_T (ip_buf)); return result; }
char * ACE_NS_WString::char_rep (void) const { ACE_TRACE ("ACE_NS_WString::char_rep"); if (this->len_ == 0) return 0; else { char *t = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (t, static_cast<char*>(ACE_Allocator::instance()->malloc (sizeof (char) * (this->len_ + 1))), 0); #else ACE_NEW_RETURN (t, char[this->len_ + 1], 0); #endif for (size_type i = 0; i < this->len_; ++i) // Note that this cast may lose data if wide chars are // actually used! t[i] = char (this->rep_[i]); t[this->len_] = '\0'; return t; } }
int ACE_Data_Block::size (size_t length) { ACE_TRACE ("ACE_Data_Block::size"); if (length <= this->max_size_) this->cur_size_ = length; else { // We need to resize! char *buf = 0; ACE_ALLOCATOR_RETURN (buf, (char *) this->allocator_strategy_->malloc (length), -1); ACE_OS::memcpy (buf, this->base_, this->cur_size_); if (ACE_BIT_DISABLED (this->flags_, ACE_Message_Block::DONT_DELETE)) this->allocator_strategy_->free ((void *) this->base_); else // We now assume ownership. ACE_CLR_BITS (this->flags_, ACE_Message_Block::DONT_DELETE); this->max_size_ = length; this->cur_size_ = length; this->base_ = buf; } return 0; }
template <class SVC_HANDLER> int ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh) { ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler"); // Open the shared library. ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_); // Extract the factory function. #if defined (ACE_OPENVMS) SVC_HANDLER *(*factory)(void) = (SVC_HANDLER *(*)(void)) ACE::ldsymbol (handle, this->factory_function_); #else SVC_HANDLER *(*factory)(void) = (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle, this->factory_function_); #endif // Call the factory function to obtain the new SVC_Handler (should // use RTTI here when it becomes available...) SVC_HANDLER *svc_handler = 0; ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1); if (svc_handler != 0) { // Create an ACE_Service_Type containing the SVC_Handler and // insert into this->svc_rep_; ACE_Service_Type_Impl *stp = 0; ACE_NEW_RETURN (stp, ACE_Service_Object_Type (svc_handler, this->svc_name_), -1); ACE_Service_Type *srp = 0; ACE_NEW_RETURN (srp, ACE_Service_Type (this->svc_name_, stp, handle, 1), -1); if (srp == 0) { delete stp; errno = ENOMEM; return -1; } if (this->svc_rep_->insert (srp) == -1) return -1; // @@ Somehow, we need to deal with this->thr_mgr_... } sh = svc_handler; return 0; }
int ACE_SPIPE_Addr::set (const ACE_TCHAR *addr, gid_t gid, uid_t uid) { int len = sizeof (this->SPIPE_addr_.uid_); len += sizeof (this->SPIPE_addr_.gid_); #if defined (ACE_WIN32) const ACE_TCHAR *colonp = ACE_OS::strchr (addr, ':'); ACE_TCHAR temp[BUFSIZ]; if (colonp == 0) // Assume it's a local name. { ACE_OS::strcpy (temp, ACE_TEXT ( "\\\\.\\pipe\\")); ACE_OS::strcat (temp, addr); } else { if (ACE_OS::strncmp (addr, ACE_TEXT ("localhost"), ACE_OS::strlen ("localhost")) == 0) // change "localhost" to "." ACE_OS::strcpy (temp, ACE_TEXT ("\\\\.")); else { ACE_OS::strcpy (temp, ACE_TEXT ("\\\\")); ACE_TCHAR *t; // We need to allocate a duplicate so that we can write a // NUL character into it. ACE_ALLOCATOR_RETURN (t, ACE_OS::strdup (addr), -1); t[colonp - addr] = ACE_TEXT ('\0'); ACE_OS::strcat (temp, t); ACE_OS::free (t); } ACE_OS::strcat (temp, ACE_TEXT ("\\pipe\\")); ACE_OS::strcat (temp, colonp + 1); } len += static_cast<int> (ACE_OS::strlen (temp)); this->ACE_Addr::base_set (AF_SPIPE, len); ACE_OS::strcpy (this->SPIPE_addr_.rendezvous_, temp); #else this->ACE_Addr::base_set (AF_SPIPE, ACE_OS::strlen (addr) + 1 + len); ACE_OS::strsncpy (this->SPIPE_addr_.rendezvous_, addr, sizeof this->SPIPE_addr_.rendezvous_); #endif /* ACE_WIN32 */ this->SPIPE_addr_.gid_ = gid == 0 ? ACE_OS::getgid () : gid; this->SPIPE_addr_.uid_ = uid == 0 ? ACE_OS::getuid () : uid; return 0; }
int ACE_FTP_Addr::set (const ACE_FTP_Addr& addr) { if (this->ACE_URL_Addr::set (addr) != 0) return -1; this->clear (); ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (addr.hostname_), -1); ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (addr.path_), -1); if (addr.user_ != 0) ACE_ALLOCATOR_RETURN (this->user_, ACE_OS::strdup (addr.user_), -1); else this->user_ = 0; if (addr.password_ != 0) ACE_ALLOCATOR_RETURN (this->password_, ACE_OS::strdup (addr.password_), -1); else this->password_ = 0; return 0; }
int ACE_URL_Addr::string_to_addr (const ACE_TCHAR *address) { if (this->url_ != 0) ACE_OS::free (this->url_); if (address == 0) return -1; ACE_ALLOCATOR_RETURN (this->url_, ACE_OS::strdup (address), -1); return 0; }
int ACEXML_URL_Addr::set (const ACEXML_URL_Addr &addr) { ACE_OS::free (this->path_name_); ACE_OS::free (this->addr_string_); if (this->ACE_INET_Addr::set (addr) == -1) return -1; else { if (addr.path_name_) ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (addr.path_name_), -1); if (addr.addr_string_) ACE_ALLOCATOR_RETURN (this->addr_string_, ACE_OS::strdup (addr.addr_string_), -1); this->addr_string_len_ = addr.addr_string_len_; return 0; } }
int ACEXML_URL_Addr::string_to_addr (const ACEXML_Char* s, int /*address_family */) { if (s == 0) return -1; const ACEXML_Char* http = ACE_TEXT ("http://"); size_t http_len = ACE_OS::strlen (http); // Check validity of URL if (ACE_OS::strncmp (http, s, http_len) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Invalid URL %s\n"), s), -1); const ACEXML_Char* url = 0; // Get the host name for (url = s + http_len; *url != '\0' && *url != ':' && *url != '/'; ++url) ; size_t host_len = url - s; host_len -= http_len; ACEXML_Char* host_name = 0; ACE_NEW_RETURN (host_name, ACEXML_Char[host_len + 1], -1); ACE_OS::strncpy (host_name, s + http_len, host_len); host_name[host_len] = '\0'; ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_host_name (host_name); // Get the port number (if any) unsigned short port = ACE_DEFAULT_HTTP_PORT; if (*url == ':') { port = (unsigned short) ACE_OS::strtol (++url, 0, 10); // Skip over ':' while ( *url != '\0' && *url != '/' ) ++url; } // Set the addr int result = this->ACE_INET_Addr::set (port, host_name); if (result == -1) return -1; // Get the path name const ACEXML_Char* path_name = 0; if (*url == '\0') path_name = ACE_TEXT ("/"); else path_name = url; ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (path_name), -1); return result; }
int ACE_HTTP_Addr::set (const ACE_HTTP_Addr &addr) { if (this->ACE_URL_Addr::set (addr) != 0) return -1; this->clear (); if (addr.hostname_ != 0) ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (addr.hostname_), -1); else ACE_ALLOCATOR_RETURN (this->hostname_, ACE_OS::strdup (ACE_TEXT ("")), -1); if (addr.path_ != 0) ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (addr.path_), -1); else ACE_ALLOCATOR_RETURN (this->path_, ACE_OS::strdup (ACE_TEXT ("")), -1); this->port_number_ = addr.port_number_; if (addr.query_ != 0) ACE_ALLOCATOR_RETURN (this->query_, ACE_OS::strdup (addr.query_), -1); else this->query_ = 0; return 0; }
int ACE_Log_Record::print (const ACE_TCHAR host_name[], u_long verbose_flag, FILE *fp) { if ( log_priority_enabled(this->category(), ACE_Log_Priority (this->type_)) ) { ACE_TCHAR *verbose_msg = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (verbose_msg, static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXVERBOSELOGMSGLEN)), -1); #else ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); #endif /* ACE_HAS_ALLOC_HOOKS */ int result = this->format_msg (host_name, verbose_flag, verbose_msg, MAXVERBOSELOGMSGLEN); if (result == 0) { if (fp != 0) { int const verbose_msg_len = static_cast<int> (ACE_OS::strlen (verbose_msg)); #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) int const fwrite_result = ACE_OS::fprintf (fp, ACE_TEXT ("%ls"), verbose_msg); #else int const fwrite_result = ACE_OS::fprintf (fp, ACE_TEXT ("%s"), verbose_msg); #endif // We should have written everything if (fwrite_result != verbose_msg_len) result = -1; else ACE_OS::fflush (fp); } } #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(verbose_msg); #else delete [] verbose_msg; #endif /* ACE_HAS_ALLOC_HOOKS */ return result; } else return 0; }
template <class ACE_CHAR_T> ACE_CHAR_T * ACE_String_Base<ACE_CHAR_T>::rep (void) const { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::rep"); ACE_CHAR_T *new_string; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (new_string, static_cast<ACE_CHAR_T*>(ACE_Allocator::instance()->malloc(sizeof(ACE_CHAR_T) * (this->len_ + 1))), 0); #else ACE_NEW_RETURN (new_string, ACE_CHAR_T[this->len_ + 1], 0); #endif ACE_OS::strsncpy (new_string, this->rep_, this->len_+1); return new_string; }
template <class ACE_CHAR_T> ACE_String_Base<ACE_CHAR_T> & ACE_String_Base<ACE_CHAR_T>::append (const ACE_CHAR_T* s, typename ACE_String_Base<ACE_CHAR_T>::size_type slen) { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::append(const ACE_CHAR_T*, size_type)"); if (slen > 0 && slen != npos) { // case 1. No memory allocation needed. if (this->buf_len_ >= this->len_ + slen + 1) { // Copy in data from new string. ACE_OS::memcpy (this->rep_ + this->len_, s, slen * sizeof (ACE_CHAR_T)); } else // case 2. Memory reallocation is needed { const size_type new_buf_len = ace_max(this->len_ + slen + 1, this->buf_len_ + this->buf_len_ / 2); ACE_CHAR_T *t = 0; ACE_ALLOCATOR_RETURN (t, (ACE_CHAR_T *) this->allocator_->malloc (new_buf_len * sizeof (ACE_CHAR_T)), *this); // Copy memory from old string into new string. ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (ACE_CHAR_T)); ACE_OS::memcpy (t + this->len_, s, slen * sizeof (ACE_CHAR_T)); if (this->buf_len_ != 0 && this->release_) this->allocator_->free (this->rep_); this->release_ = true; this->rep_ = t; this->buf_len_ = new_buf_len; } this->len_ += slen; this->rep_[this->len_] = 0; } return *this; }
const ACEXML_Char * ACEXML_URL_Addr::addr_to_string (int ipaddr_format) { size_t size = this->calculate_length (ipaddr_format); if (size > this->addr_string_len_) { ACE_ALLOCATOR_RETURN (this->addr_string_, (ACEXML_Char *) ACE_OS::realloc(this->addr_string_, size), 0); this->addr_string_len_ = size; } ACE_OS::sprintf (this->addr_string_, ACE_TEXT ("%s:%d/%s"), ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0 ? this->get_host_name () : this->get_host_addr ()), this->get_port_number (), this->get_path_name ()); return this->addr_string_; }
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::bind_i (const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *&entry) { size_t loc; int result = this->shared_find (ext_id, entry, loc); ACE_Unbounded_Set<INT_ID> int_id_set; if (result == -1) { void *ptr; // Not found. ACE_ALLOCATOR_RETURN (ptr, this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>)), -1); int_id_set.insert (int_id); entry = new (ptr) ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> (ext_id, int_id_set, this->table_[loc].next_, &this->table_[loc]); this->table_[loc].next_ = entry; entry->next_->prev_ = entry; this->cur_size_++; return 0; } else { int_id_set = (*entry).int_id_set_; if (0 == int_id_set.insert (int_id)) { this->unbind_i (entry); return this->bind_i (ext_id, int_id_set); } else return 1; } }
int ACE_DLL_Manager::open (int size) { ACE_TRACE ("ACE_DLL_Manager::open"); ACE_DLL_Handle **temp = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (temp, static_cast<ACE_DLL_Handle**> (ACE_Allocator::instance()->malloc(sizeof (ACE_DLL_Handle*) * size)), -1); #else ACE_NEW_RETURN (temp, ACE_DLL_Handle *[size], -1); #endif /* ACE_HAS_ALLOC_HOOKS */ this->handle_vector_ = temp; this->total_size_ = size; return 0; }
int ACE_INET_Addr::string_to_addr (const char s[]) { ACE_TRACE ("ACE_INET_Addr::string_to_addr"); int result; char *ip_addr; // Need to make a duplicate since we'll be overwriting the string. ACE_ALLOCATOR_RETURN (ip_addr, ACE_OS::strdup (s), -1); // We use strrchr because of IPv6 addresses. char *port_p = ACE_OS::strrchr (ip_addr, ':'); if (port_p == 0) // Assume it's a port number. { char *endp = 0; u_short port = static_cast<u_short> (ACE_OS::strtol (ip_addr, &endp, 10)); if (port > 0 && *endp == '\0') result = this->set (port, ACE_UINT32 (INADDR_ANY)); else // port name result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY)); } else { *port_p = '\0'; ++port_p; // skip over ':' char *endp = 0; u_short port = static_cast<u_short> (ACE_OS::strtol (port_p, &endp, 10)); if (port > 0 && *endp == '\0') result = this->set (port, ip_addr); else result = this->set (port_p, ip_addr); } ACE_OS::free (ACE_MALLOC_T (ip_addr)); return result; }
int Handler_Factory::create_handler ( ACE_SSL_SOCK_Acceptor &acceptor, Handler * (*handler_factory) (ACE_SSL_SOCK_Stream* ), const char *handler_type) { ACE_SSL_SOCK_Stream* new_stream; ACE_NEW_RETURN (new_stream, ACE_SSL_SOCK_Stream, -1); if (acceptor.accept (*new_stream) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("accept")), -1); Handler *handler; ACE_ALLOCATOR_RETURN (handler, (*handler_factory) (new_stream), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) spawning %s handler\n"), handler_type)); if (handler->open () == -1) return -1; #if defined (ACE_MT_SAFE) // Spawn a new thread and run the new connection in that thread of // control using the <server> function as the entry point. return handler->activate (); #else handler->svc (); handler->close (0); return 0; #endif /* ACE_HAS_THREADS */ }