Skip to content

Instantly share code, notes, and snippets.

@avestura
Created February 22, 2022 21:22
Show Gist options
  • Save avestura/eb959c78cea4f0c0688329a63e86c3ce to your computer and use it in GitHub Desktop.
Save avestura/eb959c78cea4f0c0688329a63e86c3ce to your computer and use it in GitHub Desktop.
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