dylanmc / cs393_vm_api

Virtual memory abstraction & methods for constructing, accessing, manipulating and destroying address spaces
4 stars 28 forks source link

`AddressSpace::remove_mapping` should take `MapEntry` #14

Open rileyshahar opened 1 year ago

rileyshahar commented 1 year ago

Want to raise this as a discussion issue rather than just writing the PR, but I think that remove_mapping should just take a MapEntry as argument. In particular, this will let us use the borrow checker to check lifetimes of mappings, since remove_mapping will drop the MapEntry, so we can guarantee that the user no longer has a reference to it after it's removed. (On a broader note, this is why I don't like the idea of "fighting the borrow-checker": this is a case where we can make the borrow-checker work for us to ensure correctness, not just to ensure memory safety.)

rileyshahar commented 1 year ago

If we wanted to let users remove pieces of mappings, this wouldn't work, but per class we just want them to be able to remove a whole mapping at a time.