diff options
author | Like Ma <likemartinma@gmail.com> | 2019-01-29 11:54:12 +0800 |
---|---|---|
committer | Like Ma <likemartinma@gmail.com> | 2019-01-29 21:05:40 +0800 |
commit | 00772bbfe4756c5904b85b095538c5ea0167e382 (patch) | |
tree | b7fea6f90b1cdae432210304abf00b4a1ade4215 | |
parent | fa74870b8e6af9ff87c6c2a38612e25e5d78f7e4 (diff) | |
download | ATCD-00772bbfe4756c5904b85b095538c5ea0167e382.tar.gz |
Add thread safe ACE_MEM_Addr::get_host_addr.
-rw-r--r-- | ACE/ace/MEM_Addr.h | 16 | ||||
-rw-r--r-- | ACE/ace/MEM_Addr.inl | 8 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ACE/ace/MEM_Addr.h b/ACE/ace/MEM_Addr.h index 2944fa9fc7b..09fff5c1ace 100644 --- a/ACE/ace/MEM_Addr.h +++ b/ACE/ace/MEM_Addr.h @@ -105,7 +105,21 @@ public: */ const char *get_host_name (void) const; - /// Return the "dotted decimal" external address. + /** + * Return the "dotted decimal" external Internet address representation of + * the hostname storing it in the @a addr (which is assumed to be + * @a addr_size bytes long). This version is reentrant. + */ + const char *get_host_addr (char *addr, int addr_size) const; + + /** + * Return the "dotted decimal" external Internet address representation of + * the hostname. This version is non-reentrant since it returns a + * pointer to a static data area. You should therefore either + * (1) do a "deep copy" of the address returned by get_host_addr(), e.g., + * using strdup() or (2) use the "reentrant" version of + * get_host_addr() described above. + */ const char *get_host_addr (void) const; /// Return the 4-byte external IP address, converting it into host byte diff --git a/ACE/ace/MEM_Addr.inl b/ACE/ace/MEM_Addr.inl index 13d351de6a8..f849070acfb 100644 --- a/ACE/ace/MEM_Addr.inl +++ b/ACE/ace/MEM_Addr.inl @@ -46,6 +46,14 @@ ACE_MEM_Addr::get_host_addr (void) const return this->external_.get_host_addr (); } +/// Return the "dotted decimal" external address. +ACE_INLINE const char * +ACE_MEM_Addr::get_host_addr (char *addr, int addr_size) const +{ + ACE_TRACE ("ACE_MEM_Addr::get_host_addr"); + return this->external_.get_host_addr (addr, addr_size); +} + /// Return the 4-byte IP address, converting it into host byte order. ACE_INLINE ACE_UINT32 ACE_MEM_Addr::get_ip_address (void) const |