Re: Buggy __free(kfree) usage pattern already in tree
From: Linus Torvalds
Date: Fri Sep 15 2023 - 17:26:59 EST
On Fri, 15 Sept 2023 at 14:18, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> Hmm, perhaps I can do a class for it and write the thing like:
.. crossed emails.
Yes.
Except I think a full-fledged class thing is overkill for a one-time
use, and I think you really could just write it out as plain "this is
the constructor, this is the cleanup".
Yes, yes, that is obviously what our CLASS() thing *is*, but at least
my personal mental model is that a "class" is for when you really
export it to other uses.
If you just have a one-off, you don't need the class abstraction to
export to anybody else. You just do a one-off "alloc like this, free
like this".
Again, this I think is really just a "mental model" rather than any hard rule.
Linus