Thread overview | |||||
---|---|---|---|---|---|
|
January 29, 2014 toStringz in std.file | ||||
---|---|---|---|---|
| ||||
Hi! Why in std.file toStringz used without store a pointer in function body to prevent GC collection? https://github.com/D-Programming-Language/phobos/blob/master/std/file.d Best Regards, Ilya |
January 29, 2014 Re: toStringz in std.file | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Yaroshenko | On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko wrote:
> Hi!
>
> Why in std.file toStringz used without store a pointer in
> function body to prevent GC collection?
>
> https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
>
> Best Regards,
> Ilya
It is assumed that the pointer is not moved to the C heap where the GC can't see it. The stack is the stack; it doesn't matter if it's a D or C function, the GC sees it anyway.
|
January 29, 2014 Re: toStringz in std.file | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jakob Ovrum | On Wednesday, 29 January 2014 at 08:29:42 UTC, Jakob Ovrum wrote:
> On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko wrote:
>> Hi!
>>
>> Why in std.file toStringz used without store a pointer in
>> function body to prevent GC collection?
>>
>> https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
>>
>> Best Regards,
>> Ilya
>
> It is assumed that the pointer is not moved to the C heap where the GC can't see it. The stack is the stack; it doesn't matter if it's a D or C function, the GC sees it anyway.
Thanks!
|
Copyright © 1999-2021 by the D Language Foundation