From 5383e28ea0d98e76bb625949dc38b90cee2f2b5b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 22 Sep 2008 20:12:15 -0700 Subject: 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 --- src/runtime/string.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/runtime') 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); +} -- cgit v1.3