Memory leak with BufMap

Hi :slight_smile:

My understanding of the documentation of BufMap is that the deinit should take care of freeing all the entries (keys and values) along with the backing storage (it’s also my understanding of its implementation). Now the following test reports a memory leak:

test "simple test" {
    const gpa = std.testing.allocator;
    var map = std.BufMap.init(gpa);
    errdefer map.deinit();
    try map.put("alice", "bob");
}

What did I miss?
I’m on version 0.17.0.

Youre only calling deinit when an err occurs. Use defer instead of errdefer

arf, I got the couple defer / errdefer wrong… I should re-read the manual…