diff options
author | Jakob Borg <jakob@nym.se> | 2014-06-18 23:57:22 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-06-19 01:02:32 +0200 |
commit | 4dbce32738ac610f8cabc8db2133580f31dbadee (patch) | |
tree | 2a21d7c2cf36bfb1d8940f9d035e1866a4253e96 /beacon | |
parent | b05fcbc9d72dda356989bad150ada80b690bea64 (diff) |
Simplify memory handling
Diffstat (limited to 'beacon')
-rw-r--r-- | beacon/beacon.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/beacon/beacon.go b/beacon/beacon.go index 8ad7176117..f2bfd46a12 100644 --- a/beacon/beacon.go +++ b/beacon/beacon.go @@ -52,7 +52,7 @@ func (b *Beacon) Recv() ([]byte, net.Addr) { } func (b *Beacon) reader() { - var bs = make([]byte, 65536) + bs := make([]byte, 65536) for { n, addr, err := b.conn.ReadFrom(bs) if err != nil { @@ -62,8 +62,11 @@ func (b *Beacon) reader() { if debug { l.Debugf("recv %d bytes from %s", n, addr) } + + c := make([]byte, n) + copy(c, bs) select { - case b.outbox <- recv{bs[:n], addr}: + case b.outbox <- recv{c, addr}: default: if debug { l.Debugln("dropping message") |