OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [go-string-to-int-array.c] - Blame information for rev 750

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* go-string-to-int-array.c -- convert a string to an array of ints in Go.
2
 
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.  */
6
 
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"
13
 
14
struct __go_open_array
15
__go_string_to_int_array (struct __go_string str)
16
{
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;
23
 
24
  c = 0;
25
  p = str.__data;
26
  pend = p + str.__length;
27
  while (p < pend)
28
    {
29
      int rune;
30
 
31
      ++c;
32
      p += __go_get_rune (p, pend - p, &rune);
33
    }
34
 
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)
40
    {
41
      int rune;
42
 
43
      p += __go_get_rune (p, pend - p, &rune);
44
      *pd++ = rune;
45
    }
46
 
47
  ret.__values = (void *) data;
48
  ret.__count = c;
49
  ret.__capacity = c;
50
  return ret;
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.