Исходники и презентации
This commit is contained in:
23
lessons/allocator/arena_problem_3/main.go
Normal file
23
lessons/allocator/arena_problem_3/main.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
// GOEXPERIMENT=arenas go run main.go
|
||||
// go run -tags goexperiment.arenas main.go
|
||||
|
||||
import (
|
||||
"arena"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
deposit int
|
||||
credit int
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := arena.NewArena()
|
||||
data := arena.New[Data](a)
|
||||
a.Free()
|
||||
|
||||
// use after free
|
||||
fmt.Println(data)
|
||||
}
|
||||
Reference in New Issue
Block a user