A question about moving GC
Walter Bright
newshound at digitalmars.com
Wed Jun 7 12:36:58 PDT 2006
Stewart Gordon wrote:
> Walter Bright wrote:
>> Max Samuha wrote:
>>> Thank you for the extensive explanation!
>>> Marking my code with '// !!! Passing a pointer to C.' is what i've
>>> been doing recently:) and it seems the best solution for now until
>>> ares is mature or phobos has pin/unpin, or pointers passed to C are
>>> pinned implicitly.
>>
>> They will be pinned implicitly, no need to call pin/unpin. The only
>> time you're going to have a problem is if the C routine hides the
>> pointer in a malloc'd buffer where the gc won't see it. The gc *will*
>> see pointers on the C stack.
>
> Would it remain pinned indefinitely, until the C function exits, or
> until the program explicitly unpins it by some means?
It's pinned because it's on the stack, just like pointers on the stack
for your D functions. The gc doesn't know the difference.
More information about the Digitalmars-d-learn
mailing list