当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_ALLOCATOR_RETURN函数代码示例

本文整理汇总了C++中ACE_ALLOCATOR_RETURN函数的典型用法代码示例。如果您正苦于以下问题:C++ ACE_ALLOCATOR_RETURN函数的具体用法?C++ ACE_ALLOCATOR_RETURN怎么用?C++ ACE_ALLOCATOR_RETURN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ACE_ALLOCATOR_RETURN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ACE_ALLOCATOR_RETURN

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;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:29,代码来源:URL_Addr.cpp

示例2: ACE_ALLOCATOR_RETURN

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;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:25,代码来源:URL_Addr.cpp

示例3: strlen

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;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:60,代码来源:URL_Addr.cpp

示例4: init_buffer

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;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:27,代码来源:SSL-server-poll.cpp

示例5: ACE_ALLOCATOR_RETURN

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;
}
开发者ID:mbert,项目名称:mulberry-lib-jx,代码行数:29,代码来源:Array_Base.cpp

示例6: ACE_ALLOCATOR_RETURN

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;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:28,代码来源:Hash_Map_Manager_T.cpp

示例7: createIndex

// 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;
}
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:26,代码来源:PersistenceUpdater.cpp

示例8: ACE_TRACE

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;
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:59,代码来源:Strategies_T.cpp

示例9: sizeof

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;
}
开发者ID:Akenyshka,项目名称:MythCore,代码行数:59,代码来源:SPIPE_Addr.cpp

示例10: ACE_ALLOCATOR_RETURN

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;
    }
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:21,代码来源:URL_Addr.cpp

示例11: ACE_TRACE

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;
    }
}
开发者ID:binary42,项目名称:OCI,代码行数:29,代码来源:SString.cpp

示例12: ACE_TRACE

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;
}
开发者ID:eSDK,项目名称:eSDKClient_Soultion,代码行数:60,代码来源:INET_Addr.cpp

示例13: ACE_TRACE

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;
}
开发者ID:Archives,项目名称:try,代码行数:31,代码来源:Message_Block.cpp

示例14: ACE_TEXT

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;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:53,代码来源:URL_Addr.cpp

示例15: defined

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;
}
开发者ID:binary42,项目名称:OCI,代码行数:51,代码来源:Log_Record.cpp


注:本文中的ACE_ALLOCATOR_RETURN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。