Deutsch   English   Français   Italiano  
<vhsejh$1m6qu$7@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: The Natural Philosopher <tnp@invalid.invalid>
Newsgroups: comp.os.linux.misc
Subject: Re: Joy of this, Joy of that
Date: Sat, 23 Nov 2024 11:34:08 +0000
Organization: A little, after lunch
Lines: 32
Message-ID: <vhsejh$1m6qu$7@dont-email.me>
References: <vhigot$1uakf$1@dont-email.me>
 <6iKdnTQOKNh6AqD6nZ2dnZfqn_idnZ2d@earthlink.com>
 <20241120081039.00006d2a@gmail.com> <vhlium$93kn$1@dont-email.me>
 <vhmprp$iaf1$1@dont-email.me> <lq9h4kF2tegU1@mid.individual.net>
 <vhpmo6$14s79$1@dont-email.me> <wwva5drk0m1.fsf@LkoBDZeT.terraraq.uk>
 <vhptgf$1614q$1@dont-email.me> <Iq40P.70904$EQue.62359@fx13.iad>
 <slrnvk1qft.5gg9.candycanearter07@candydeb.host.invalid>
 <mcf0P.211278$pZ%.68099@fx16.iad> <vhs153$1k6ft$3@dont-email.me>
 <wwvjzcu1chd.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Nov 2024 12:34:09 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d66e216f27af22ed0cfed08003360025";
	logging-data="1776478"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+QpkURqdaSKI7YTV7ZOngR/y6ZXVR82q0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Bt5QHVerncBPMKmMv7TRZfH3NUw=
Content-Language: en-GB
In-Reply-To: <wwvjzcu1chd.fsf@LkoBDZeT.terraraq.uk>
Bytes: 2610

On 23/11/2024 10:16, Richard Kettlewell wrote:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Sat, 23 Nov 2024 07:09:06 GMT, Charlie Gibbs wrote:
>>> So it's the good old-fashioned way - free
>>> each allocation one by one and hope you don't forget one.
>>
>> One thing that helps is that free(3) is idempotent:
> 
> It is not. Freeing the same non-null pointer twice is a bug (and a
> common source of vulnerabilities).
> 
>> calling it on a NULL pointer is a harmless no-op, so there is no need
>> to check for NULL before calling it. So my standard technique
>> (simplifying somewhat) is
> 
> ‘free() and null out all copies of the pointer that can ever reach
> free() in the future’ is idempotent, if you can get it right (which is
> usually not too hard in a well-organized program).
> 
I had to read that three times to understand what you said there.

A comma after the first free() would have helped.:-)

Otherwise +100


-- 
For every complex problem there is an answer that is clear, simple, and 
wrong.

H.L.Mencken