* decl.c (get_atexit_node): Remove dead code.
[official-gcc.git] / libgo / runtime / go-string-to-int-array.c
blobaff146872a9e506314499c95ff3a2c689d51e19f
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. */
7 #include "go-alloc.h"
8 #include "go-string.h"
9 #include "array.h"
10 #include "runtime.h"
11 #include "arch.h"
12 #include "malloc.h"
14 struct __go_open_array
15 __go_string_to_int_array (struct __go_string str)
17 size_t c;
18 const unsigned char *p;
19 const unsigned char *pend;
20 uint32_t *data;
21 uint32_t *pd;
22 struct __go_open_array ret;
24 c = 0;
25 p = str.__data;
26 pend = p + str.__length;
27 while (p < pend)
29 int rune;
31 ++c;
32 p += __go_get_rune (p, pend - p, &rune);
35 data = (uint32_t *) runtime_mallocgc (c * sizeof (uint32_t), FlagNoPointers,
36 1, 0);
37 p = str.__data;
38 pd = data;
39 while (p < pend)
41 int rune;
43 p += __go_get_rune (p, pend - p, &rune);
44 *pd++ = rune;
47 ret.__values = (void *) data;
48 ret.__count = c;
49 ret.__capacity = c;
50 return ret;