File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style
33// license that can be found in the LICENSE file.
44
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
66
77package os
88
Original file line number Diff line number Diff line change @@ -51,3 +51,22 @@ func ByteSliceFromString(s string) ([]byte, error) {
5151 copy (a , s )
5252 return a , nil
5353}
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