A further thought on the include-file cleanup: although you are right to
be wary of removing includes of system files, it would be a good idea to
remove *redundant* includes of system files.
In particular, since c.h includes <stdlib.h>, as well as <stddef.h>
and <stdarg.h> if they exist, it should not be necessary for any file
that includes c.h (either directly or via postgres.h) to pull these
in for itself. Removing the "retail" inclusions of these files that
are found in many source files would make life much easier for anyone
trying to port to a platform where they don't exist...
Also, I think some places include c.h without having included
postgres.h. These should be checked to ensure that config.h has
been included first --- c.h depends on configuration symbols from
config.h to work properly.
regards, tom lane