1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:54:44 -07:00

runtime: don't allocate a new string in snprintf

This fixes the Plan 9 build.

Fix issue 8621.

LGTM=iant
R=rsc, mattn.jp, iant
CC=golang-codereviews
https://golang.org/cl/135280043
This commit is contained in:
David du Colombier 2014-09-03 00:56:50 +02:00
parent b3f224b280
commit d8cbbe6802

View File

@ -54,7 +54,7 @@ func snprintf(dst *byte, n int32, s *byte) {
gp := getg()
gp.writebuf = buf[0:0 : n-1] // leave room for NUL, this is called from C
vprintf(gostring(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
vprintf(gostringnocopy(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
buf[len(gp.writebuf)] = '\x00'
gp.writebuf = nil
}