Created
February 22, 2022 21:22
-
-
Save avestura/eb959c78cea4f0c0688329a63e86c3ce to your computer and use it in GitHub Desktop.
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
const std = @import("std"); | |
fn printaddr(a : anytype) void { | |
const stdout = std.io.getStdOut().writer(); | |
stdout.print("address = {s}\n", .{&a}) catch unreachable; | |
} | |
fn foo() void { | |
const s1 = "literal"; | |
printaddr(s1); | |
} | |
fn bar() void { | |
foo(); | |
} | |
fn baz() void { | |
bar(); | |
} | |
fn foo2() void { | |
const s2 = "literal"; | |
printaddr(s2); | |
} | |
fn bar2() void { | |
foo2(); | |
} | |
fn baz2() void { | |
bar2(); | |
} | |
pub fn main() void { | |
const bigarr: [1000]u8 = std.mem.zeroes([1000]u8); | |
baz(); | |
std.time.sleep(10_000); | |
var bigarr2: [1000]u8 = std.mem.zeroes([1000]u8); | |
std.mem.copy(u8, bigarr2[0..], bigarr[0..]); | |
baz2(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment