Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The solution to that is to either:

1) If you're gonna return pointers, don't use an allocation scheme that invalidates pointers in the implementation of map_t.

2) If you want to reallocate and move memory, don't return pointers, return abstracted handles/indices.

Both of those are completely possible and not particularly unergonomic to do in C. If you need to enforce invariants, then enforce them, C does have enough abstraction level for that.



Handles for the win, I never understood why we don't use handles for all dynamic memory.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: