fix incorrect munmap of modified p ptr.
var scoping reduction
coding style fixes
use define for MAP_FAILED