Does returned pointer by std.HashMap.getPtr get invalid after inserting values?

I think it gets invalid, encountered some segfaults, well since std.ArrayList didn’t expose any getPtr function thought std.HashMap.getPtr wouldn’t invalid the previous pointer

It does. You can use lockPointers to put the hash map in a state where pointer invalidation triggers an assertion. If you want stable pointers, see segmented list.

3 Likes