diff options
| author | Keith Randall <khr@golang.org> | 2014-09-11 16:53:34 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2014-09-11 16:53:34 -0700 |
| commit | bcd36e8857729f6f3306ab22c26e582f1d2f2932 (patch) | |
| tree | c11e1290f55082500ce5e09ddc819a87f320a912 /src/runtime/string.c | |
| parent | 6e55f7a87b8400073119612c0a3bd3f443b69f14 (diff) | |
| download | go-bcd36e8857729f6f3306ab22c26e582f1d2f2932.tar.xz | |
runtime: make gostringnocopy update maxstring
Fixes #8706
LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/143880043
Diffstat (limited to 'src/runtime/string.c')
| -rw-r--r-- | src/runtime/string.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/string.c b/src/runtime/string.c index 811a289060..ed5debc33e 100644 --- a/src/runtime/string.c +++ b/src/runtime/string.c @@ -42,10 +42,15 @@ String runtime·gostringnocopy(byte *str) { String s; + uintptr ms; s.str = str; s.len = runtime·findnull(str); - return s; + while(true) { + ms = runtime·maxstring; + if(s.len <= ms || runtime·casp((void**)&runtime·maxstring, (void*)ms, (void*)s.len)) + return s; + } } // TODO: move this elsewhere |
