2011-04-21 Tobias Burnus <burnus@net-b.de>
[official-gcc.git] / libgo / syscalls / stringbyte.go
blobb673c9b02bb26647475373e8022a6b9b4d05ae0d
1 // stringbyte.go -- string to bytes functions.
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 package syscall
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];
16 return a;
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];