From 3b30c6e0b548aebad0a1db2ff5795870bbc37f3c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 10 Jan 2012 10:46:55 +0100 Subject: [PATCH] Need to work even harder to fix the length, but this is much better --- msg.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/msg.go b/msg.go index 3f0e6a05..6c325ba2 100644 --- a/msg.go +++ b/msg.go @@ -975,10 +975,8 @@ func (dns *Msg) Pack() (msg []byte, ok bool) { dh.Nscount = uint16(len(ns)) dh.Arcount = uint16(len(extra)) - // Could work harder to calculate message size, - // but this is far more than we need and not - // big enough to hurt the allocator. - msg = make([]byte, DefaultMsgSize) // TODO, calculate REAL size + // TODO: still too much, but better than 64K + msg = make([]byte, dns.Len()*8) // Pack it in: header and then the pieces. off := 0