Either I'm confused or the gc is

Ali Çehreli acehreli at yahoo.com
Sun Nov 15 21:46:52 UTC 2020

On 11/15/20 10:43 AM, Steven Schveighoffer wrote:

 > I also did not see the toStringz as a problem
 > when I reviewed.

While I have everbody's attention, :) toStringz will come up during one 
of my DConf presentations. I will claim that it is safe to pass to a C 
function for their immediate consumption (but they can't save the pointer).

So, I will claim that the following is safe and no GC collection on 
another thread can mess this up. (The C side is not allowed to store for 
later use but they are taking the pointer into a local variable on their 
function call stack.)

nothrow extern(C) void bar(const(char) ** name) {
   // ...
   *name = makeString(42).toStringz;
   // ...

My claim is based on my understanding on the following thread. (Thank 
you, Rikki Cattermole.)



More information about the Digitalmars-d mailing list