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
        • Re: DIP10... Paolo Invernizzi via Digitalmars-d-announce
        • Re: DIP10... Steven Schveighoffer via Digitalmars-d-announce
          • Re: D... Atila Neves via Digitalmars-d-announce
            • ... ag0aep6g via Digitalmars-d-announce
            • ... Atila Neves via Digitalmars-d-announce
            • ... Dukc via Digitalmars-d-announce
            • ... Steven Schveighoffer via Digitalmars-d-announce
            • ... Joseph Rushton Wakeling via Digitalmars-d-announce
            • ... Paolo Invernizzi via Digitalmars-d-announce
            • ... Walter Bright via Digitalmars-d-announce
            • ... Steven Schveighoffer via Digitalmars-d-announce
        • Re: DIP10... ag0aep6g via Digitalmars-d-announce
          • Re: D... Atila Neves via Digitalmars-d-announce
            • ... ag0aep6g via Digitalmars-d-announce
            • ... Paul Backus via Digitalmars-d-announce
            • ... Mathias LANG via Digitalmars-d-announce
            • ... Dominikus Dittes Scherkl via Digitalmars-d-announce
  • Re: DIP1028 - Rational... jmh530 via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Timon Gehr via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Adam D. Ruppe via Digitalmars-d-announce

Reply via email to