I have discovered that Zig function parameters are constant. That means my naive function for freeing a HashMap
doesn't work. You can see an example of the code here. I am wondering if the most correct Zig way is to pass dict
as a function or if there is some other way in which I can make a parameter mutable.
const Dict = std.StringHashMap;
fn releaseDict(allocator: Allocator, dict: Dict(i16)) void {
var iter = dict.iterator();
while (iter.next()) |entry|
allocator.free(entry.key_ptr.*);
dict.deinit();
}