Bump date stamp to 20131126
[official-gcc.git] / libgo / runtime / go-string-to-byte-array.c
blob5e030330f29533c9d341a951fe967b8308d87621
1 /* go-string-to-byte-array.c -- convert a string to an array of bytes 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 "runtime.h"
8 #include "array.h"
9 #include "arch.h"
10 #include "malloc.h"
12 struct __go_open_array
13 __go_string_to_byte_array (String str)
15 unsigned char *data;
16 struct __go_open_array ret;
18 data = (unsigned char *) runtime_mallocgc (str.len, 0,
19 FlagNoScan | FlagNoZero);
20 __builtin_memcpy (data, str.str, str.len);
21 ret.__values = (void *) data;
22 ret.__count = str.len;
23 ret.__capacity = str.len;
24 return ret;