mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-15 10:18:01 +08:00
Problem: inconsistent control structures in address.cpp, redundant check for NULLness before delete
Solution: harmonize, remove redundant checks
This commit is contained in:
parent
0179b7577a
commit
9c8fde09ca
@ -57,67 +57,46 @@ zmq::address_t::address_t (const std::string &protocol_,
|
|||||||
zmq::address_t::~address_t ()
|
zmq::address_t::~address_t ()
|
||||||
{
|
{
|
||||||
if (protocol == protocol_name::tcp) {
|
if (protocol == protocol_name::tcp) {
|
||||||
if (resolved.tcp_addr) {
|
LIBZMQ_DELETE (resolved.tcp_addr);
|
||||||
LIBZMQ_DELETE (resolved.tcp_addr);
|
} else if (protocol == protocol_name::udp) {
|
||||||
}
|
LIBZMQ_DELETE (resolved.udp_addr);
|
||||||
}
|
|
||||||
if (protocol == protocol_name::udp) {
|
|
||||||
if (resolved.udp_addr) {
|
|
||||||
LIBZMQ_DELETE (resolved.udp_addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
|
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
|
||||||
&& !defined ZMQ_HAVE_VXWORKS
|
&& !defined ZMQ_HAVE_VXWORKS
|
||||||
else if (protocol == protocol_name::ipc) {
|
else if (protocol == protocol_name::ipc) {
|
||||||
if (resolved.ipc_addr) {
|
LIBZMQ_DELETE (resolved.ipc_addr);
|
||||||
LIBZMQ_DELETE (resolved.ipc_addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined ZMQ_HAVE_TIPC
|
#if defined ZMQ_HAVE_TIPC
|
||||||
else if (protocol == protocol_name::tipc) {
|
else if (protocol == protocol_name::tipc) {
|
||||||
if (resolved.tipc_addr) {
|
LIBZMQ_DELETE (resolved.tipc_addr);
|
||||||
LIBZMQ_DELETE (resolved.tipc_addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined ZMQ_HAVE_VMCI
|
#if defined ZMQ_HAVE_VMCI
|
||||||
else if (protocol == protocol_name::vmci) {
|
else if (protocol == protocol_name::vmci) {
|
||||||
if (resolved.vmci_addr) {
|
LIBZMQ_DELETE (resolved.vmci_addr);
|
||||||
LIBZMQ_DELETE (resolved.vmci_addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::address_t::to_string (std::string &addr_) const
|
int zmq::address_t::to_string (std::string &addr_) const
|
||||||
{
|
{
|
||||||
if (protocol == protocol_name::tcp) {
|
if (protocol == protocol_name::tcp && resolved.tcp_addr)
|
||||||
if (resolved.tcp_addr)
|
return resolved.tcp_addr->to_string (addr_);
|
||||||
return resolved.tcp_addr->to_string (addr_);
|
if (protocol == protocol_name::udp && resolved.udp_addr)
|
||||||
}
|
return resolved.udp_addr->to_string (addr_);
|
||||||
if (protocol == protocol_name::udp) {
|
|
||||||
if (resolved.udp_addr)
|
|
||||||
return resolved.udp_addr->to_string (addr_);
|
|
||||||
}
|
|
||||||
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
|
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
|
||||||
&& !defined ZMQ_HAVE_VXWORKS
|
&& !defined ZMQ_HAVE_VXWORKS
|
||||||
else if (protocol == protocol_name::ipc) {
|
if (protocol == protocol_name::ipc && resolved.ipc_addr)
|
||||||
if (resolved.ipc_addr)
|
return resolved.ipc_addr->to_string (addr_);
|
||||||
return resolved.ipc_addr->to_string (addr_);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined ZMQ_HAVE_TIPC
|
#if defined ZMQ_HAVE_TIPC
|
||||||
else if (protocol == protocol_name::tipc) {
|
if (protocol == protocol_name::tipc && resolved.tipc_addr)
|
||||||
if (resolved.tipc_addr)
|
return resolved.tipc_addr->to_string (addr_);
|
||||||
return resolved.tipc_addr->to_string (addr_);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined ZMQ_HAVE_VMCI
|
#if defined ZMQ_HAVE_VMCI
|
||||||
else if (protocol == protocol_name::vmci) {
|
if (protocol == protocol_name::vmci && resolved.vmci_addr)
|
||||||
if (resolved.vmci_addr)
|
return resolved.vmci_addr->to_string (addr_);
|
||||||
return resolved.vmci_addr->to_string (addr_);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!protocol.empty () && !address.empty ()) {
|
if (!protocol.empty () && !address.empty ()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user