- https://www.drips.network/app/drip-lists/30178668158349445547603108732480118476541651095408979232800331391215?ethereum_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&optimism_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&filecoin_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&zksync_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38dðereum_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&optimism_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&filecoin_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d&zksync_owned_by=0x341a08926dCa7fa7D135F96E4d76b696e5f6d38d
- https://bb.com
- https://cc.com
- https://dd.com
This file contains hidden or 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
main { | |
A = 1 // create A | |
loop { | |
B = 2 // create B | |
// delete B | |
} | |
// delete A | |
} |
This file contains hidden or 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
main { | |
A = allocate() // acquire | |
do_stuff(A) // use | |
release(A) // release | |
// delete pointer | |
} |
This file contains hidden or 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
main { | |
A = allocate() // acquire | |
do_stuff(A) // use | |
// <RUN TIME FAIL> never release | |
// delete pointer | |
} |
This file contains hidden or 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
main { | |
A = allocate() // acquire | |
release(A) // release | |
do_stuff(A) // <RUN TIME FAIL> use invalid pointer | |
// delete pointer | |
} |
This file contains hidden or 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
main { | |
A = allocate() // acquire | |
do_stuff(A) // use | |
release(A) // release | |
release(A) // <RUN TIME FAIL> release invalid pointer | |
// delete pointer | |
} |
This file contains hidden or 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
main { | |
... | |
A = <pointer to>──────┐ | |
... | | |
} │ | |
▼ | |
╔══ HEAP ALLOCATED ════════╗ | |
║ AA = "reachable" ║ | |
║ AB = <pointer to>──────┐ ║ | |
╚════════════════════════│═╝ |
This file contains hidden or 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
main { | |
A = allocate() // acquire | |
do_stuff(A) // use | |
release(A) // release, pointer owns allocation | |
// delete pointer | |
} | |
do_stuff(B) { | |
do_more_stuff(B) // use | |
// don't release, pointer doesn't own allocation |
This file contains hidden or 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
main { | |
A = allocate() // A's lifetime begins | |
do_stuff(A) // use A | |
B = A // B's lifetime begins | |
do_stuff(B) // use B | |
release(A) // release, A's and B's lifetimes end | |
do_stuff(A) // <RUN TIME FAIL> use A after its lifetime ended | |
do_stuff(B) // <RUN TIME FAIL> use B after its lifetime ended | |
} |
This file contains hidden or 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
fn my_fn() { | |
let my_box = Box::new(1234); // acquire | |
println!("{}", my_box); // use | |
// delete my_box, | |
// which releases memory | |
} |
This file contains hidden or 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
struct MyStruct { // structure definition | |
my_box: Box<u32>, // it has only 1 field, | |
// a Box keeping integer on heap | |
} | |
fn my_fn() { | |
let my_struct = MyStruct { // create instance of structure | |
my_box: Box::new(1234), // acquire memory | |
}; | |
println!("{}", my_struct.my_box); // use |
OlderNewer