Created
December 16, 2014 02:23
-
-
Save ikawaha/913dd300105e00242ba1 to your computer and use it in GitHub Desktop.
メモリの確保のされ方の確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[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