Fix memory_access.h for OS X.
Fix casting warnings