Re: [PATCH 1/2] diff: add an API for deferred freeing
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 11, 2021, 09:40 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2102111039080.29765@tvgsbejvaqbjf.bet>
- In-Reply-To
- <878s7vcnqo.fsf@evledraar.gmail.com>
Hi Ævar,
On Thu, 11 Feb 2021, Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> On Wed, Feb 10 2021, Johannes Schindelin wrote: > > > On Fri, 5 Feb 2021, Ævar Arnfjörð Bjarmason wrote: > > > >> Add a diff_free() function to free anything we may have allocated in > >> the "diff_options" struct, and the ability to make calling it a noop > >> by setting "no_free" in "diff_options". > > > > Why do we need a `no_free` flag? Why not simply set the `free()`d (or > > `fclose()`d) attributes to `NULL`?
Hmm. That was not even clear to me until I read this reply.
Doesn't this indicate that the closing is done at the wrong layer? If we want to call a function N times and only at the last iteration should it clean up our resources, doesn't that indicate that the clean-up should be pulled out from that function?
I thought that's exactly what you did, but I must have glanced over something obvious...
Ciao, Dscho