libpq: Remove redundant null pointer checks before free()

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-06-16T20:07:33Z
Lists: pgsql-hackers

Attachments

libpq contains a lot of

     if (foo)
         free(foo);

calls, where the "if" part is unnecessary.  This is of course pretty 
harmless, but some functions like scram_free() and freePGconn() have 
become so bulky that it becomes annoying.  So while I was doing some 
work in that area I undertook to simplify this.

Commits

  1. Remove redundant null pointer checks before PQclear and PQconninfoFree

  2. Remove redundant null pointer checks before free()

  3. Remove redundant null pointer checks before pg_free()