File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || wasip1 || wasip2 || windows
5
+ //go:build aix || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || wasip1 || windows
6
6
7
7
package os
8
8
Original file line number Diff line number Diff line change @@ -51,3 +51,22 @@ func ByteSliceFromString(s string) ([]byte, error) {
51
51
copy (a , s )
52
52
return a , nil
53
53
}
54
+
55
+ func SlicePtrFromStrings (ss []string ) ([]* byte , error ) {
56
+ n := 0
57
+ for _ , s := range ss {
58
+ if IndexByteString (s , 0 ) != - 1 {
59
+ return nil , EINVAL
60
+ }
61
+ n += len (s ) + 1 // +1 for NUL
62
+ }
63
+ bb := make ([]* byte , len (ss )+ 1 )
64
+ b := make ([]byte , n )
65
+ n = 0
66
+ for i , s := range ss {
67
+ bb [i ] = & b [n ]
68
+ copy (b [n :], s )
69
+ n += len (s ) + 1
70
+ }
71
+ return bb , nil
72
+ }
You can’t perform that action at this time.
0 commit comments