wgengine/magicsock: remove allocs in UDP write, use new netaddr.PutUDPAddr

The allocs were only introduced yesterday with a TODO. Now they're gone again.
This commit is contained in:
Brad Fitzpatrick
2020-07-01 10:17:08 -07:00
parent 7b3c0bb7f6
commit 9b8ca219a1
3 changed files with 6 additions and 3 deletions

View File

@@ -805,8 +805,9 @@ var errDropDerpPacket = errors.New("too many DERP packets queued; dropping")
// sendUDP sends UDP packet b to ipp.
func (c *Conn) sendUDP(ipp netaddr.IPPort, b []byte) error {
addr := ipp.UDPAddr() // TOOD(bradfitz): add alloc-free netaddr.WriteTo helper
return c.sendUDPStd(addr, b)
ua := ipp.UDPAddr()
defer netaddr.PutUDPAddr(ua)
return c.sendUDPStd(ua, b)
}
func (c *Conn) sendUDPStd(addr *net.UDPAddr, b []byte) (err error) {