// +build !appengine,!tinygo

package fwd

import (
	"reflect"
	"unsafe"
)

// unsafe cast string as []byte
func unsafestr(b string) []byte {
	l := len(b)
	return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
		Len:  l,
		Cap:  l,
		Data: (*reflect.StringHeader)(unsafe.Pointer(&b)).Data,
	}))
}

// +build !appengine,!tinygo

package fwd

import (
	"reflect"
	"unsafe"
)

// unsafe cast string as []byte
func unsafestr(s string) []byte {
	var b []byte
	sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
	bHdr := (*reflect.SliceHeader)(unsafe.Pointer(&b))
	bHdr.Data = sHdr.Data
	bHdr.Len = sHdr.Len
	bHdr.Cap = sHdr.Len
	return b
}

Fix invalid usage of reflect.SliceHeader
Fix invalid usage of reflect.SliceHeader

Using plain reflect.SliceHeader struct violates unsafe pointer 6th rule.
