mirror of
https://github.com/miekg/dns.git
synced 2025-09-29 12:01:02 +02:00
PackBuffer: slight cleanup in docs
This commit is contained in:
parent
7f8964662e
commit
00a08d77fc
7
msg.go
7
msg.go
@ -1293,7 +1293,8 @@ func (dns *Msg) Pack() (msg []byte, err error) {
|
|||||||
return dns.PackBuffer(nil)
|
return dns.PackBuffer(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackWithBuffer packs a Msg, reusing a given buffer if possible to reduce memory allocations
|
// PackBuffer packs a Msg, using the given buffer buf. If buf is too small
|
||||||
|
// a new buffer is allocated.
|
||||||
func (dns *Msg) PackBuffer(buf []byte) (msg []byte, err error) {
|
func (dns *Msg) PackBuffer(buf []byte) (msg []byte, err error) {
|
||||||
var dh Header
|
var dh Header
|
||||||
var compression map[string]int
|
var compression map[string]int
|
||||||
@ -1341,8 +1342,8 @@ func (dns *Msg) PackBuffer(buf []byte) (msg []byte, err error) {
|
|||||||
dh.Arcount = uint16(len(extra))
|
dh.Arcount = uint16(len(extra))
|
||||||
|
|
||||||
msg = buf
|
msg = buf
|
||||||
if packLen := dns.packLen(); len(msg) <= packLen {
|
if packLen := dns.packLen()+1; len(msg) < packLen {
|
||||||
msg = make([]byte, packLen+1)
|
msg = make([]byte, packLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack it in: header and then the pieces.
|
// Pack it in: header and then the pieces.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user