Fix freelocale.
Add platform macro to support non-bsd platform.