Re: libpq: Remove redundant null pointer checks before free()

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Michael Paquier <michael@paquier.xyz>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-06-19T17:38:31Z
Lists: pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> For PQclear() specifically, one thing that I thought a few days ago
> would be useful would to have it return (PGresult *) NULL.  Then the
> very common pattern of doing "PQclear(res); res = NULL;" could be
> simplified to "res = PQclear(res);", which is nicely compact and is
> learned instantly.

That's a public API unfortunately, and so some people would demand
a libpq.so major version bump if we changed it.

			regards, tom lane



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()