MCPcopy Create free account
hub / github.com/golang/mobile / cString

Method cString

gl/work_windows.go:73–83  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

71}
72
73func (ctx *context) cString(s string) (uintptr, func()) {
74 buf := make([]byte, len(s)+1)
75 for i := 0; i < len(s); i++ {
76 buf[i] = s[i]
77 }
78 ret := unsafe.Pointer(&buf[0])
79 id := ctx.cStringCounter
80 ctx.cStringCounter++
81 ctx.cStrings[id] = ret
82 return uintptr(ret), func() { delete(ctx.cStrings, id) }
83}
84
85func (ctx *context) cStringPtr(str string) (uintptr, func()) {
86 s, sfree := ctx.cString(str)

Callers 1

cStringPtrMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected