modernise reflect.SliceHeader to unsafe.Slice

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-05-19 12:58:35 +02:00
parent 20826e87d8
commit fed9970582
2 changed files with 10 additions and 29 deletions

View File

@@ -28,7 +28,6 @@ import "C"
import (
"math"
"reflect"
"unsafe"
)
@@ -91,9 +90,11 @@ func (c *SQLiteContext) ResultNull() {
// ResultText sets the result of an SQL function.
// See: sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html
func (c *SQLiteContext) ResultText(s string) {
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
cs, l := (*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len)
C.my_result_text((*C.sqlite3_context)(c), cs, l)
if len(s) == 0 {
C.my_result_text((*C.sqlite3_context)(c), (*C.char)(unsafe.Pointer(&placeHolder[0])), 0)
return
}
C.my_result_text((*C.sqlite3_context)(c), (*C.char)(unsafe.Pointer(unsafe.StringData(s))), C.int(len(s)))
}
// ResultZeroblob sets the result of an SQL function.