Source file
test/notinheap3.go
Documentation: test
1
2
3
4
5
6
7
8
9 package p
10
11 type t1 struct {
12 x *nih
13 s []nih
14 y [1024]byte
15 }
16
17 type t2 struct {
18 x *ih
19 s []ih
20 y [1024]byte
21 }
22
23
24 type nih struct {
25 x uintptr
26 }
27
28 type ih struct {
29 x uintptr
30 }
31
32 var (
33 v1 t1
34 v2 t2
35
36 v1s []t1
37 v2s []t2
38 )
39
40 func f() {
41
42 v1.x = nil
43 v2.x = nil
44 v1.s = []nih(nil)
45 v2.s = []ih(nil)
46 }
47
48 func g() {
49
50 v1 = t1{x: nil}
51 v2 = t2{x: nil}
52 }
53
54 func h() {
55
56 copy(v1s, v1s[1:])
57 copy(v2s, v2s[1:])
58 _ = append(v1s, v1s...)
59 _ = append(v2s, v2s...)
60 }
61
62
63
64 var (
65 sliceIH []*ih
66 sliceNIH []*nih
67 )
68
69 func sliceClear() {
70 for i := range sliceIH {
71 sliceIH[i] = nil
72 }
73 for i := range sliceNIH {
74 sliceNIH[i] = nil
75 }
76 }
77
View as plain text