News for hackers. Stuff that matters.
Re:Custom Allocators in Rust by throwawaymaths on Saturday April 08, 2023 @01:20PM (#35495478)
I think realistically if you want to prove safety of memory provenance in zig, you assume that allocators are sound, and you just track the lifetime of the memory from alloc/create to free/destroy and call it a day. This is probably "good enough", and in rust you're assuming the allocation is sound as well, it's just implicit.
Re:Custom Allocators in Rust by anonymoushn on Saturday April 08, 2023 @07:18PM (#35498587)
What you get for free with the global allocator is a guarantee that you will use the same allocator for each operation on an allocation. That is the property that is claimed to be difficult to keep if you literally do the Zig thing and have e.g. ArrayListUnmanaged which requires you to pass in the allocator again to free the backing slice.
Re:Custom Allocators in Rust by throwawaymaths on Sunday April 09, 2023 @01:10AM (#35500215)
Ok so those are 'unsafe'. Plenty of safe (when statically checked) data structures in zig, like the managed array list, where the associated allocator is attached to the object.