1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-12-09 09:56:01 +02:00
imgproxy/vips/cached_c_strings.go

18 lines
255 B
Go
Raw Normal View History

2021-04-26 13:52:50 +02:00
package vips
import "C"
2021-12-10 15:42:32 +02:00
import "sync"
2021-12-10 15:42:32 +02:00
var cStringsCache sync.Map
func cachedCString(str string) *C.char {
2021-12-10 15:42:32 +02:00
if cstr, ok := cStringsCache.Load(str); ok {
return cstr.(*C.char)
}
cstr := C.CString(str)
2021-12-10 15:42:32 +02:00
cStringsCache.Store(str, cstr)
return cstr
}