0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-15 02:07:59 +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:
Simon Giesecke 2018-05-30 13:30:19 +02:00 committed by Simon Giesecke
parent 0179b7577a
commit 9c8fde09ca

View File

@ -57,67 +57,46 @@ zmq::address_t::address_t (const std::string &protocol_,
zmq::address_t::~address_t ()
{
if (protocol == protocol_name::tcp) {
if (resolved.tcp_addr) {
LIBZMQ_DELETE (resolved.tcp_addr);
}
}
if (protocol == protocol_name::udp) {
if (resolved.udp_addr) {
LIBZMQ_DELETE (resolved.udp_addr);
}
LIBZMQ_DELETE (resolved.tcp_addr);
} else if (protocol == protocol_name::udp) {
LIBZMQ_DELETE (resolved.udp_addr);
}
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
&& !defined ZMQ_HAVE_VXWORKS
else if (protocol == protocol_name::ipc) {
if (resolved.ipc_addr) {
LIBZMQ_DELETE (resolved.ipc_addr);
}
LIBZMQ_DELETE (resolved.ipc_addr);
}
#endif
#if defined ZMQ_HAVE_TIPC
else if (protocol == protocol_name::tipc) {
if (resolved.tipc_addr) {
LIBZMQ_DELETE (resolved.tipc_addr);
}
LIBZMQ_DELETE (resolved.tipc_addr);
}
#endif
#if defined ZMQ_HAVE_VMCI
else if (protocol == protocol_name::vmci) {
if (resolved.vmci_addr) {
LIBZMQ_DELETE (resolved.vmci_addr);
}
LIBZMQ_DELETE (resolved.vmci_addr);
}
#endif
}
int zmq::address_t::to_string (std::string &addr_) const
{
if (protocol == protocol_name::tcp) {
if (resolved.tcp_addr)
return resolved.tcp_addr->to_string (addr_);
}
if (protocol == protocol_name::udp) {
if (resolved.udp_addr)
return resolved.udp_addr->to_string (addr_);
}
if (protocol == protocol_name::tcp && resolved.tcp_addr)
return resolved.tcp_addr->to_string (addr_);
if (protocol == protocol_name::udp && resolved.udp_addr)
return resolved.udp_addr->to_string (addr_);
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
&& !defined ZMQ_HAVE_VXWORKS
else if (protocol == protocol_name::ipc) {
if (resolved.ipc_addr)
return resolved.ipc_addr->to_string (addr_);
}
if (protocol == protocol_name::ipc && resolved.ipc_addr)
return resolved.ipc_addr->to_string (addr_);
#endif
#if defined ZMQ_HAVE_TIPC
else if (protocol == protocol_name::tipc) {
if (resolved.tipc_addr)
return resolved.tipc_addr->to_string (addr_);
}
if (protocol == protocol_name::tipc && resolved.tipc_addr)
return resolved.tipc_addr->to_string (addr_);
#endif
#if defined ZMQ_HAVE_VMCI
else if (protocol == protocol_name::vmci) {
if (resolved.vmci_addr)
return resolved.vmci_addr->to_string (addr_);
}
if (protocol == protocol_name::vmci && resolved.vmci_addr)
return resolved.vmci_addr->to_string (addr_);
#endif
if (!protocol.empty () && !address.empty ()) {