Replace custom checks with Autoconf macros
Removing environ in legacy/trac#19142 (moved) didn't work on BSDs but the check in configure.ac can be simplified. Autoconf provides the AC_CHECK_DECL macro for these kinds of checks and turns the current check into a oneliner.
The malloc(0) check can also be simplified by replacing it with the AC_FUNC_MALLOC macro.
These are only two candidates I've found so far, there are probably more hence this ticket.