8-pointer/

directory
v0.0.0-...-31eefd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2022 License: MIT

README

Pointer

Stack

内存中的 Stack 会存储方法和本地变量:

假设在 main方法 中声明一个 变量 1,在将 变量 1 的 copy 作为参数传递到 方法 1 中,这样就会有这样一个 stack:

|变量 1 的 copy|
|方法 1|
|变量 1|
|main 方法|

在执行 方法 1 的时候,变量 1 的 copy方法 1 会被弹出,所以 stack 就只剩下:

|变量 1|
|main方法|

所以,当执行 方法 1 的时候,无论 变量 1 的 copy 发生什么变化,stack 中的 变量 1 都是无法识别的。

Address

变量都会有一个 Address(地址)。

假设有一个 string 类型的变量 a:var a string = "123"

那么 a 在内存中大致上就是 地址 + 值

| 0x123 | "abc" |

那么 a 的 pointer 大致上就是 地址 + 存储 a 地址的值

| 0x234 | 0x123 |

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL