MCPcopy Index your code
hub / github.com/coder/coder / createEnvBlock

Function createEnvBlock

pty/start_windows.go:139–160  ·  view source on GitHub ↗

Taken from: https://github.com/microsoft/hcsshim/blob/7fbdca16f91de8792371ba22b7305bf4ca84170a/internal/exec/exec.go#L476

(envv []string)

Source from the content-addressed store, hash-verified

137
138// Taken from: https://github.com/microsoft/hcsshim/blob/7fbdca16f91de8792371ba22b7305bf4ca84170a/internal/exec/exec.go#L476
139func createEnvBlock(envv []string) *uint16 {
140 if len(envv) == 0 {
141 return &utf16.Encode([]rune("\x00\x00"))[0]
142 }
143 length := 0
144 for _, s := range envv {
145 length += len(s) + 1
146 }
147 length += 1
148
149 b := make([]byte, length)
150 i := 0
151 for _, s := range envv {
152 l := len(s)
153 copy(b[i:i+l], []byte(s))
154 copy(b[i+l:i+l+1], []byte{0})
155 i = i + l + 1
156 }
157 copy(b[i:i+1], []byte{0})
158
159 return &utf16.Encode([]rune(string(b)))[0]
160}
161
162// dedupEnvCase is dedupEnv with a case option for testing.
163// If caseInsensitive is true, the case of keys is ignored.

Callers 1

startPtyFunction · 0.85

Calls 1

EncodeMethod · 0.80

Tested by

no test coverage detected