Re: Collection of memory leaks for ECPG driver - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Collection of memory leaks for ECPG driver
Date
Msg-id 4940.1434168160@sss.pgh.pa.us
Whole thread Raw
In response to Re: Collection of memory leaks for ECPG driver  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Collection of memory leaks for ECPG driver  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Michael Paquier <michael.paquier@gmail.com> writes:
> On Fri, Jun 12, 2015 at 10:01 PM, Michael Meskes <meskes@postgresql.org> wrote:
>> More seriously, though, does anyone know of any platform where free(NULL) is *not* a noop?

> I recall reading that some past versions of SunOS crashed, but it is
> rather old...

Yeah, SunOS 4.x had issues here, but it's long dead.  More to the point,
both C89 and Single Unix Spec v2 clearly say that free(NULL) is a no-op;
and it's been many years since we agreed that we had no interest in
supporting platforms that didn't meet at least those minimum standards.
So there is no need to worry about any code of ours that does free(NULL).

But having said that, I would not be in a hurry to remove any existing
if-guards for the case.  For one thing, it makes the code look more
similar to backend code that uses palloc/pfree, where we do *not* allow
pfree(NULL).  There's also the point that changing longstanding code
creates back-patching hazards, so unless there's a clear gain it's best
not to.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Time to fully remove heap_formtuple() and friends?
Next
From: Peter Geoghegan
Date:
Subject: Re: Time to fully remove heap_formtuple() and friends?