Rename dupIP to copyIP

Also make the function shorter.
This commit is contained in:
Miek Gieben 2014-01-12 10:09:54 +00:00
parent a56060b558
commit 3342ee9d85
1 changed files with 9 additions and 10 deletions

View File

@ -165,12 +165,11 @@ const (
_LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2.
)
// helper: duplicate net.IP structure (it's a []byte)
func dupIP(ip net.IP) net.IP {
var ip2 net.IP
ip2 = make([]byte, len(ip))
copy(ip2, ip)
return ip2
// copyID returns a copy of ip.
func copyIP(ip net.IP) net.IP {
p := make(net.IP, len(ip))
copy(p, ip)
return p
}
// DNS queries.
@ -594,7 +593,7 @@ type A struct {
}
func (rr *A) Header() *RR_Header { return &rr.Hdr }
func (rr *A) copy() RR { return &A{*rr.Hdr.copyHeader(), dupIP(rr.A)} }
func (rr *A) copy() RR { return &A{*rr.Hdr.copyHeader(), copyIP(rr.A)} }
func (rr *A) len() int { return rr.Hdr.len() + net.IPv4len }
func (rr *A) String() string {
@ -610,7 +609,7 @@ type AAAA struct {
}
func (rr *AAAA) Header() *RR_Header { return &rr.Hdr }
func (rr *AAAA) copy() RR { return &AAAA{*rr.Hdr.copyHeader(), dupIP(rr.AAAA)} }
func (rr *AAAA) copy() RR { return &AAAA{*rr.Hdr.copyHeader(), copyIP(rr.AAAA)} }
func (rr *AAAA) len() int { return rr.Hdr.len() + net.IPv6len }
func (rr *AAAA) String() string {
@ -1272,7 +1271,7 @@ func (rr *WKS) len() int { return rr.Hdr.len() + net.IPv4len + 1 }
func (rr *WKS) copy() RR {
cp := make([]uint16, len(rr.BitMap), cap(rr.BitMap))
copy(cp, rr.BitMap)
return &WKS{*rr.Hdr.copyHeader(), dupIP(rr.Address), rr.Protocol, cp}
return &WKS{*rr.Hdr.copyHeader(), copyIP(rr.Address), rr.Protocol, cp}
}
func (rr *WKS) String() (s string) {
@ -1311,7 +1310,7 @@ type L32 struct {
}
func (rr *L32) Header() *RR_Header { return &rr.Hdr }
func (rr *L32) copy() RR { return &L32{*rr.Hdr.copyHeader(), rr.Preference, dupIP(rr.Locator32)} }
func (rr *L32) copy() RR { return &L32{*rr.Hdr.copyHeader(), rr.Preference, copyIP(rr.Locator32)} }
func (rr *L32) len() int { return rr.Hdr.len() + net.IPv4len }
func (rr *L32) String() string {