Get the latest tech news

Resizable structs in Zig


In this post I will make the case for the concept of a “runtime resizable struct” in Zig. I will then design an API by exploiting Zig’s powerful comptime functionality.

If you don’t track all of the lengths, you can accidentally introduce undefined behavior, and as a result, possible security vulnerabilities. We can actually achieve something sort of like this with some good ’ole Zig flavored comptime meta programming. The ResizableStruct(Layout) will act as a utility type that makes working with pointers to each field easier.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of zig

zig

Photo of Resizable Structs

Resizable Structs

Related news:

News photo

Zig's New Writer

News photo

Zig's new I/O: function coloring is inevitable?

News photo

Zig's New Async I/O