net: use `vmemset(&hints, 0, int(sizeof(hints)))`, instead of zeroing the fields 1 by 1

pull/12564/head
Delyan Angelov 2021-11-24 09:34:48 +02:00
parent e42db5bee2
commit 8e0de2036d
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 2 additions and 5 deletions

View File

@ -173,14 +173,11 @@ pub fn resolve_ipaddrs(addr string, family AddrFamily, typ SocketType) ?[]Addr {
// ai_socktype: int(typ)
// ai_flags: C.AI_PASSIVE
}
unsafe { vmemset(&hints, 0, int(sizeof(hints))) }
hints.ai_family = int(family)
hints.ai_socktype = int(typ)
hints.ai_flags = C.AI_PASSIVE
hints.ai_protocol = 0
hints.ai_addrlen = 0
hints.ai_addr = voidptr(0)
hints.ai_canonname = voidptr(0)
hints.ai_next = voidptr(0)
results := &C.addrinfo(0)
sport := '$port'