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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 747 jeremybenn
/* go-string-to-byte-array.c -- convert a string to an array of bytes 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-string.h"
8
#include "array.h"
9
#include "runtime.h"
10
#include "arch.h"
11
#include "malloc.h"
12
 
13
struct __go_open_array
14
__go_string_to_byte_array (struct __go_string str)
15
{
16
  unsigned char *data;
17
  struct __go_open_array ret;
18
 
19
  data = (unsigned char *) runtime_mallocgc (str.__length, FlagNoPointers, 1, 0);
20
  __builtin_memcpy (data, str.__data, str.__length);
21
  ret.__values = (void *) data;
22
  ret.__count = str.__length;
23
  ret.__capacity = str.__length;
24
  return ret;
25
}

powered by: WebSVN 2.1.0

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