llgo/ssa: Go const string

This commit is contained in:
xushiwei
2024-04-30 18:37:31 +08:00
parent ae0906d322
commit d62bf858dd
2 changed files with 14 additions and 9 deletions

View File

@@ -40,6 +40,11 @@ func EmptyString() String {
return String{nil, 0}
}
// NewString creates a new string.
func NewString(data unsafe.Pointer, len int) String {
return String{data, len}
}
// StringLen returns the length of a string.
func StringLen(s Slice) int {
return s.len
@@ -50,6 +55,8 @@ func StringData(s String) unsafe.Pointer {
return s.data
}
// -----------------------------------------------------------------------------
// CStrCopy copies a Go string to a C string buffer and returns it.
func CStrCopy(dest unsafe.Pointer, s String) *int8 {
n := s.len