diff options
| author | Russ Cox <rsc@golang.org> | 2008-09-22 20:12:15 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2008-09-22 20:12:15 -0700 |
| commit | 5383e28ea0d98e76bb625949dc38b90cee2f2b5b (patch) | |
| tree | 5d561790898a6c054c44143964008578cef54a3b /src/runtime/string.c | |
| parent | c13c03c261ddd2c21a47b7b36754573b4e1f7c44 (diff) | |
| download | go-5383e28ea0d98e76bb625949dc38b90cee2f2b5b.tar.xz | |
change string([]byte) to pass array, rather than &a[0],
to string convert. if the byte array has length 0,
the computation of &a[0] throws an index bounds error.
for fixed size arrays, this ends up invoking arrays2d
unnecessarily, but it works.
R=ken
DELTA=304 (44 added, 28 deleted, 232 changed)
OCL=15674
CL=15678
Diffstat (limited to 'src/runtime/string.c')
| -rw-r--r-- | src/runtime/string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/string.c b/src/runtime/string.c index 27a7581094..fec66f8a82 100644 --- a/src/runtime/string.c +++ b/src/runtime/string.c @@ -164,3 +164,12 @@ sys·byteastring(byte *a, int32 l, string s) mcpy(s->str, a, l); FLUSH(&s); } + +void +sys·arraystring(Array *b, string s) +{ + s = mal(sizeof(s->len)+b->nel); + s->len = b->nel; + mcpy(s->str, b->array, s->len); + FLUSH(&s); +} |
