When this will be freed?
John Colvin
john.loughran.colvin at gmail.com
Wed Apr 2 08:56:17 PDT 2014
On Wednesday, 2 April 2014 at 15:45:06 UTC, Andrea Fontana wrote:
>
> auto example(char* test) { return toStringz(to!string(test) ~ "
> world!"); }
>
> When that return string will be freed?
>
> What about:
>
> extern(C) auto example(....)
>
> ?
to!string allocates on the GC heap when given a char* (it has to,
in order to safely produce immutable data in the string).
It will be freed by the first garbage collection ocurring after
all references to that memory are dead.
More information about the Digitalmars-d-learn
mailing list