Zig, Memory, and the mysterious 170
I’m hacking on a small Zig application with a GTK frontend, and part of using GTK is passing around ?*anyopaque
pointers and you never quite know if it’s working. In my app I’m passing around a struct that holds a string []const u8
to various GTK callbacks. However the string was empty. This led me down a rabbit hole of trying to figure out if my pointers were correctly passed, even going as far as stepping through it with a debugger. Turns out, the pointers are all correct. Even my string []const u8
was there with the correct length, except every single byte was set to 170
and I realized I was looking at undefined memory. Zig in debug mode sets undefined memory to 0xaa
which is 170
.