OSDN Git Service

Solaris libgo testsuite fixes.
[pf3gnuchains/gcc-fork.git] / libgo / syscalls / stringbyte.go
1 // stringbyte.go -- string to bytes functions.
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 package syscall
8
9 // StringByteSlice returns a NUL-terminated slice of bytes
10 // containing the text of s.
11 func StringByteSlice(s string) []byte {
12         a := make([]byte, len(s)+1);
13         for i := 0; i < len(s); i++ {
14                 a[i] = s[i];
15         }
16         return a;
17 }
18
19 // StringBytePtr returns a pointer to a NUL-terminated array of bytes
20 // containing the text of s.
21 func StringBytePtr(s string) *byte {
22         p := StringByteSlice(s);
23         return &p[0];
24 }