lkml.org 
[lkml]   [2020]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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

\
 
 \ /
  Last update: 2020-09-16 09:13    [W:0.078 / U:1.992 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site