1 /* go-string-to-int-array.c -- convert a string to an array of ints in Go.
3 Copyright 2010 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
14 struct __go_open_array
15 __go_string_to_int_array (String str
)
18 const unsigned char *p
;
19 const unsigned char *pend
;
23 struct __go_open_array ret
;
33 p
+= __go_get_rune (p
, pend
- p
, &rune
);
36 if (c
> MaxMem
/ sizeof (uint32_t))
37 runtime_throw ("out of memory");
39 mem
= runtime_roundupsize (c
* sizeof (uint32_t));
40 data
= (uint32_t *) runtime_mallocgc (mem
, 0, FlagNoScan
| FlagNoZero
);
47 p
+= __go_get_rune (p
, pend
- p
, &rune
);
50 if (mem
> (uintptr
) c
* sizeof (uint32_t))
51 __builtin_memset (data
+ c
, 0, mem
- (uintptr
) c
* sizeof (uint32_t));
52 ret
.__values
= (void *) data
;
54 ret
.__capacity
= (intgo
) (mem
/ sizeof (uint32_t));