1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:07:56 -07:00

encoding/binary: document that PutVarint, PutUvarint may panic

Fixes #2628

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5571058
This commit is contained in:
Brad Fitzpatrick 2012-01-24 14:19:59 -08:00
parent fe30ed2dcf
commit 2c2c20224a

View File

@ -37,6 +37,7 @@ const (
)
// PutUvarint encodes a uint64 into buf and returns the number of bytes written.
// If the buffer is too small, PutUvarint will panic.
func PutUvarint(buf []byte, x uint64) int {
i := 0
for x >= 0x80 {
@ -73,6 +74,7 @@ func Uvarint(buf []byte) (uint64, int) {
}
// PutVarint encodes an int64 into buf and returns the number of bytes written.
// If the buffer is too small, PutVarint will panic.
func PutVarint(buf []byte, x int64) int {
ux := uint64(x) << 1
if x < 0 {