fix shared mem warnings

fixes odd warnings about not being able to delete memory regions when using osrm-datastore, and avoids a bit of code duplication.