←back to thread

lsr: ls with io_uring

(rockorager.dev)
335 points mpweiher | 1 comments | | HN request time: 0.329s | source
Show context
quibono ◴[] No.44604587[source]
Lovely, I might try doing this for some other "classic" utility!

A bit off-topic too, but I'm new to Zig and curious. This here: ``` const allocator = sfb.get();

    var cmd: Command = .{ .arena = allocator };
``` means that all allocations need to be written with an allocator in mind? I.e. one has to pick an allocator per each memory allocation? Or is there a default one?
replies(2): >>44604650 #>>44604736 #
1. kristoff_it ◴[] No.44604650[source]
Allocator is an interface so you write library code only once, and then the caller decides which concrete implementation to use.

There's cases where you do want to change your code based on the expectation that you will be provided a special kind of allocator (e.g. arenas), but that's a more niche thing and in any case it all comes together pretty well in practice.