On 5/24/21 8:38 PM, Mike Parker wrote:
On Monday, 24 May 2021 at 16:16:53 UTC, Steven Schveighoffer wrote:

This leaves a GC-collectible allocation in C land. For `puts`, it's fine, as the data is not used past the call, but in something else that might keep it somewhere not accessible to the GC, you'll want to assign that to a variable that lasts as long as the resource is used.


That's what I'm referring to in the conclusion where I say this about what's going to be in Part Two:

how to avoid a potential problem spot that can arise when passing GC-allocated D strings to C

I'll cover approaches to maintaining a reference, like `GC.addRoot`, and emphasize that it applies to any GC-allocated memory, not just strings.

OK, I'm just concerned people will see the pattern:

```d
somecfunc(str.toStringz);
```

and think that's the end of it.

-Steve

              • ... zjh via Digitalmars-d-announce
              • ... Vinod K Chandran via Digitalmars-d-announce
              • ... zjh via Digitalmars-d-announce
              • ... dangbinghoo via Digitalmars-d-announce
              • ... zjh via Digitalmars-d-announce
  • Re: From the D Blog... sighoya via Digitalmars-d-announce
  • Re: From the D Blog... Steven Schveighoffer via Digitalmars-d-announce
    • Re: From the D... John Colvin via Digitalmars-d-announce
    • Re: From the D... Mike Parker via Digitalmars-d-announce
      • Re: From t... Steven Schveighoffer via Digitalmars-d-announce
        • Re: Fr... surlymoor via Digitalmars-d-announce
          • Re... Steven Schveighoffer via Digitalmars-d-announce
        • Re: Fr... Mike Parker via Digitalmars-d-announce
  • Re: From the D Blog... Виталий Фадеев via Digitalmars-d-announce
    • Re: From the D... Виталий Фадеев via Digitalmars-d-announce
      • Re: From t... Виталий Фадеев via Digitalmars-d-announce
    • Re: From the D... Ali Çehreli via Digitalmars-d-announce
      • Re: From t... Виталий Фадеев via Digitalmars-d-announce
        • Re: Fr... Виталий Фадеев via Digitalmars-d-announce
          • Re... Виталий Фадеев via Digitalmars-d-announce

Reply via email to