Replace custom checks with Autoconf macros
Removing environ in #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.
malloc(0) check can also be simplified by replacing it with the
These are only two candidates I've found so far, there are probably more hence this ticket.