[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7cgtDq8yOFDEGEdTD9kN=Ko1gX=5o+tAB4+EDtN0WtGQPw@mail.gmail.com>
Date: Wed, 16 Sep 2020 16:12:24 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: David Malcolm <dmalcolm@...hat.com>
Cc: Ian Rogers <irogers@...gle.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Stephane Eranian <eranian@...gle.com>,
LKML <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit
Hello Ian and David,
Thank you for the good suggestions!
On Wed, Sep 16, 2020 at 4:56 AM David Malcolm <dmalcolm@...hat.com> wrote:
> Some ideas (with the caveat that I'm a GCC developer, and not a regular
> on LKML): can you capture the ownership status in the type system?
> I'm brainstorming here but how about:
> typedef char *owned_string_t;
> typedef const char *borrowed_string_t;
> This would at least capture the intent in human-readable form, and
> *might* make things more amenable to checking by a machine. It's also
> less macro cruft.
> I take it that capturing the ownership status with a runtime flag next
> to the pointer in a struct is too expensive for your code?
Adding more random thoughts..
I think we can make it more generic like __attribute__((owned))
so that it can be applied to any pointers. And we can use a
conventional macro like '__owned' in the declaration..
__owned char *name;
__owned char *strdup(const char *);
...
Thanks
Namhyung
Powered by blists - more mailing lists