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

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq: Remove redundant null pointer checks before free()
Date: 2022-06-17 19:07:58
Message-ID: 5eb1b215-acc2-9922-50d8-fc57a3e4f5e8@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 17.06.22 07:11, Tom Lane wrote:
> Having said that, the pattern "if (x) free(x);" is absolutely
> ubiquitous across our code, and so I'm not sure that I'm on
> board with undoing it only in libpq. I'd be happier if we made
> a push to get rid of it everywhere.

Sure, here is a more comprehensive patch set. (It still looks like
libpq is the largest chunk.)

> Notably, I think the choice
> that pfree(NULL) is disallowed traces directly to worries about
> coding-pattern-compatibility with pre-POSIX free(). Should we
> revisit that?

Yes please, and also repalloc().

Attachment Content-Type Size
v2-0001-Remove-redundant-null-pointer-checks-before-free.patch text/plain 45.9 KB
v2-0002-Remove-redundant-null-pointer-checks-before-pg_fr.patch text/plain 4.8 KB
v2-0003-Remove-redundant-null-pointer-checks-before-PQcle.patch text/plain 9.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-06-17 19:21:45 Re: SGML doc file references
Previous Message Peter Eisentraut 2022-06-17 19:03:23 Re: libpq: Remove redundant null pointer checks before free()