Change pfree to accept NULL argument

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Change pfree to accept NULL argument
Date: 2022-08-22 18:16:56
Message-ID: cf26e970-8e92-59f1-247a-aa265235075b@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Per discussion in [0], here is a patch set that allows pfree() to accept
a NULL argument, like free() does.

Also, a patch that removes the now-unnecessary null pointer checks
before calling pfree(). And a few patches that do the same for some
other functions that I found around. (The one with FreeDir() is perhaps
a bit arguable, since FreeDir() wraps closedir() which does *not* accept
NULL arguments. Also, neither FreeFile() nor the underlying fclose()
accept NULL.)

[0]: https://www.postgresql.org/message-id/1074830.1655442689@sss.pgh.pa.us

Attachment Content-Type Size
0001-Remove-unnecessary-casts-in-free-and-pfree.patch text/plain 2.3 KB
0002-Change-pfree-to-accept-NULL-argument.patch text/plain 1.6 KB
0003-Remove-no-longer-needed-null-pointer-checks-before-p.patch text/plain 74.3 KB
0004-Remove-unneeded-null-pointer-checks-before-PQfreemem.patch text/plain 2.7 KB
0005-Remove-unneeded-null-pointer-check-before-FreeDir.patch text/plain 710 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-08-22 18:30:22 Re: Change pfree to accept NULL argument
Previous Message Andres Freund 2022-08-22 17:36:54 Re: pg_stat_have_stats() returns true for dropped indexes (or for index creation transaction rolled back)