Messages in this thread | | | From | Namhyung Kim <> | Date | Wed, 16 Sep 2020 16:12:24 +0900 | 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@redhat.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
| |