On 5/22/20 8:05 PM, Walter Bright wrote:
On 5/22/2020 10:54 AM, Atila Neves wrote:
BTW, you should fix that invalid attribute, freeing a pointer is
never @safe unless you can guarantee nobody else has a copy of that
pointer (and considering it's passed by value, the CALLER still has
that pointer!)
You're completely right.
@live is intended to fix that!
To get ahead of the curve, annotate pointer parameters with `scope` if
you don't intend to transfer ownership to the callee. Better yet, use
`ref` instead of pointer parameters where possible.
These are extern(C) functions written in C. How does one apply @live to
that? You can't change it to ref in the prototype.
Besides, a deallocation function shouldn't use @live, it's about to
destroy the pointer.
-Steve