2018-11-15 17:11:34 +00:00
|
|
|
|
|
|
|
package common
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//go:nosplit
|
|
|
|
func NoEscape (p unsafe.Pointer) (unsafe.Pointer) {
|
|
|
|
x := uintptr (p)
|
|
|
|
return unsafe.Pointer (x ^ 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NoEscapeBytes (p *[]byte) (*[]byte) {
|
|
|
|
return (*[]byte) (NoEscape (unsafe.Pointer (&p)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func NoEscapeString (p *string) (*string) {
|
|
|
|
return (*string) (NoEscape (unsafe.Pointer (&p)))
|
|
|
|
}
|
|
|
|
|
2018-11-17 17:41:00 +00:00
|
|
|
|
|
|
|
func BytesToString (b []byte) (string) {
|
2019-08-11 22:29:04 +00:00
|
|
|
return *(*string) (unsafe.Pointer (&b))
|
|
|
|
}
|
|
|
|
|
|
|
|
func StringToBytes (s string) ([]byte) {
|
|
|
|
return *(*[]byte) (unsafe.Pointer (&s))
|
2018-11-17 17:41:00 +00:00
|
|
|
}
|
|
|
|
|