mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
avoid temporaries in qt_socket_getPortAndAddress()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4d725af061
commit
db3200f631
2 changed files with 4 additions and 10 deletions
|
@ -136,16 +136,14 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
|
|||
qDebug() << "getaddrinfo node: flags:" << node->ai_flags << "family:" << node->ai_family << "ai_socktype:" << node->ai_socktype << "ai_protocol:" << node->ai_protocol << "ai_addrlen:" << node->ai_addrlen;
|
||||
#endif
|
||||
if (node->ai_family == AF_INET) {
|
||||
QHostAddress addr;
|
||||
addr.setAddress(ntohl(((sockaddr_in *) node->ai_addr)->sin_addr.s_addr));
|
||||
QHostAddress addr(ntohl(((sockaddr_in *) node->ai_addr)->sin_addr.s_addr));
|
||||
if (!addresses.contains(addr))
|
||||
addresses.append(addr);
|
||||
}
|
||||
#ifndef QT_NO_IPV6
|
||||
else if (node->ai_family == AF_INET6) {
|
||||
QHostAddress addr;
|
||||
sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr;
|
||||
addr.setAddress(sa6->sin6_addr.s6_addr);
|
||||
QHostAddress addr(sa6->sin6_addr.s6_addr);
|
||||
if (sa6->sin6_scope_id)
|
||||
addr.setScopeId(QString::number(sa6->sin6_scope_id));
|
||||
if (!addresses.contains(addr))
|
||||
|
|
|
@ -57,9 +57,7 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
|
|||
Q_IPV6ADDR tmp;
|
||||
memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp));
|
||||
if (addr) {
|
||||
QHostAddress tmpAddress;
|
||||
tmpAddress.setAddress(tmp);
|
||||
*addr = tmpAddress;
|
||||
addr->setAddress(tmp);
|
||||
#ifndef QT_NO_IPV6IFNAME
|
||||
QSTACKARRAY(char, scopeid, IFNAMSIZ);
|
||||
if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
|
||||
|
@ -76,9 +74,7 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
|
|||
if (port)
|
||||
*port = ntohs(s->a4.sin_port);
|
||||
if (addr) {
|
||||
QHostAddress tmpAddress;
|
||||
tmpAddress.setAddress(ntohl(s->a4.sin_addr.s_addr));
|
||||
*addr = tmpAddress;
|
||||
addr->setAddress(ntohl(s->a4.sin_addr.s_addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue