- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 108 for StringHeader (0.28 sec)
-
test/fixedbugs/issue19168.go
hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" } func b(hdr *reflect.StringHeader, p *byte) { hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" } func c(hdrs *[1]reflect.SliceHeader, p *byte) { hdrs[0].Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" } func d(hdr *struct{ s reflect.StringHeader }, p *byte) { hdr.s.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Mar 02 17:21:50 UTC 2017 - 1.3K bytes - Viewed (0) -
test/strcopy.go
"unsafe" ) func main() { var ( buf = make([]byte, 2<<10) large = string(buf) sub = large[10:12] subcopy = string([]byte(sub)) subh = *(*reflect.StringHeader)(unsafe.Pointer(&sub)) subcopyh = *(*reflect.StringHeader)(unsafe.Pointer(&subcopy)) ) if subh.Data == subcopyh.Data { panic("sub and subcopy have the same underlying array") }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Jun 12 19:10:34 UTC 2018 - 674 bytes - Viewed (0) -
test/unsafe_string_data.go
// license that can be found in the LICENSE file. package main import ( "fmt" "reflect" "unsafe" ) func main() { var s = "abc" sh1 := (*reflect.StringHeader)(unsafe.Pointer(&s)) ptr2 := unsafe.Pointer(unsafe.StringData(s)) if ptr2 != unsafe.Pointer(sh1.Data) { panic(fmt.Errorf("unsafe.StringData ret %p != %p", ptr2, unsafe.Pointer(sh1.Data))) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Aug 31 17:15:15 UTC 2022 - 479 bytes - Viewed (0) -
test/escape_unsafe.go
// (6) Conversion of a reflect.SliceHeader or reflect.StringHeader // Data field to or from Pointer. func fromSliceData(s []int) unsafe.Pointer { // ERROR "leaking param: s to result ~r0 level=0$" return unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s)).Data) } func fromStringData(s string) unsafe.Pointer { // ERROR "leaking param: s to result ~r0 level=0$" return unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&s)).Data) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Sep 07 17:25:59 UTC 2022 - 2.2K bytes - Viewed (0) -
src/internal/unsafeheader/unsafeheader.go
// and string implementations. // // This package allows packages that cannot import "reflect" to use types that // are tested to be equivalent to reflect.SliceHeader and reflect.StringHeader. package unsafeheader import ( "unsafe" ) // Slice is the runtime representation of a slice. // It cannot be used safely or portably and its representation may // change in a later release. //
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri May 01 16:14:17 UTC 2020 - 1.1K bytes - Viewed (0) -
test/fixedbugs/issue8606b.go
} err = syscall.Mprotect(b, syscall.PROT_NONE) if err != nil { panic(err) } // write inaccessible pointers as the data fields of bad1 and bad2. (*reflect.StringHeader)(unsafe.Pointer(&bad1)).Data = uintptr(unsafe.Pointer(&b[0])) (*reflect.StringHeader)(unsafe.Pointer(&bad2)).Data = uintptr(unsafe.Pointer(&b[1])) for _, test := range []struct { a, b interface{} }{ {SI{s: bad1, i: 1}, SI{s: bad2, i: 2}},
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Oct 19 23:33:25 UTC 2023 - 1.9K bytes - Viewed (0) -
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go
switch x := astutil.Unparen(x).(type) { case *ast.SelectorExpr: // "(6) Conversion of a reflect.SliceHeader or // reflect.StringHeader Data field to or from Pointer." if x.Sel.Name != "Data" { break } // reflect.SliceHeader and reflect.StringHeader are okay, // but only if they are pointing at a real slice or string. // It's not okay to do: // var x SliceHeader
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Apr 02 02:20:05 UTC 2024 - 4.7K bytes - Viewed (0) -
src/unsafe/unsafe.go
// // (6) Conversion of a [reflect.SliceHeader] or [reflect.StringHeader] Data field to or from Pointer. // // As in the previous case, the reflect data structures SliceHeader and StringHeader // declare the field Data as a uintptr to keep callers from changing the result to // an arbitrary type without first importing "unsafe". However, this means that // SliceHeader and StringHeader are only valid when interpreting the content
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue May 21 19:45:20 UTC 2024 - 12.1K bytes - Viewed (0) -
test/fixedbugs/issue19743.go
type immutableBytes []byte // Bug was failure to leak param b. func toString(b immutableBytes) string { // ERROR "leaking param: b$" var s string if len(b) == 0 { return s } strHeader := (*reflect.StringHeader)(unsafe.Pointer(&s)) strHeader.Data = (*reflect.SliceHeader)(unsafe.Pointer(&b)).Data l := len(b) strHeader.Len = l return s
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Apr 02 16:34:03 UTC 2019 - 669 bytes - Viewed (0) -
test/fixedbugs/issue45045.go
import ( "reflect" "runtime" "unsafe" ) func k(c chan string, val string) string { b := make([]byte, 1000) runtime.SetFinalizer(&b[0], func(*byte) { c <- val }) var s string h := (*reflect.StringHeader)(unsafe.Pointer(&s)) h.Data = uintptr(unsafe.Pointer(&b[0])) h.Len = len(b) return s } func main() { { c := make(chan string, 2) m := make(map[string]int) m[k(c, "first")] = 0
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Sun Mar 28 03:27:04 UTC 2021 - 997 bytes - Viewed (0)