Skip to content

Instantly share code, notes, and snippets.

@ikawaha
Created December 16, 2014 02:23
Show Gist options
  • Save ikawaha/913dd300105e00242ba1 to your computer and use it in GitHub Desktop.
Save ikawaha/913dd300105e00242ba1 to your computer and use it in GitHub Desktop.
メモリの確保のされ方の確認
package main
import "fmt"
import "unsafe"
type code [4]byte
type tape []code
func main() {
var c code = code{1,2,3,4}
fmt.Println(c)
var t tape
for i := 0; i < 10; i++ {
t = append(t, c)
}
fmt.Println(t)
for i := 0; i < 10; i++ {
p := unsafe.Pointer(&t[i])
fmt.Println(p)
}
}
@ikawaha
Copy link
Author

ikawaha commented Dec 16, 2014

[1 2 3 4]
[[1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4]]
0x10352040
0x10352044
0x10352048
0x1035204c
0x10352050
0x10352054
0x10352058
0x1035205c
0x10352060
0x10352064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment