PHP-737: Remove invalid argument casting

https://jira.mongodb.org/browse/PHP-737

Also includes a second commit to make the error message `malloc()` more conservative and consistent with what we do elsewhere.