mirror of https://github.com/mattn/go-sqlite3.git
18 lines
372 B
Go
18 lines
372 B
Go
//go:build !go1.21
|
|
// +build !go1.21
|
|
|
|
package sqlite3
|
|
|
|
import "unsafe"
|
|
|
|
// stringData is a safe version of unsafe.StringData that handles empty strings.
|
|
func stringData(s string) *byte {
|
|
if len(s) != 0 {
|
|
b := *(*[]byte)(unsafe.Pointer(&s))
|
|
return &b[0]
|
|
}
|
|
// The return value of unsafe.StringData
|
|
// is unspecified if the string is empty.
|
|
return &placeHolder[0]
|
|
}
|