#Can I depend on std.mem.Allocator.free checking for empty slices?
1 messages · Page 1 of 1 (latest)
yes, the values returned from alloc and create depend on this behavior, since they return arbitrary pointer values for zero-length allocations
std.ArrayList also takes advantage of this: https://github.com/ziglang/zig/blob/53d7a7b3c023f0c26ae7ecc070645096d9adb3dd/lib/std/array_list.zig#L55
Thanks!