On Saturday, 5 August 2017 at 21:18:29 UTC, Jeremy DeHaan wrote:
On Saturday, 5 August 2017 at 20:17:23 UTC, bitwise wrote:
I have a Windows native window class in C++, and I need a function to return the window title.

[...]

As long as you have a reachable reference to the GC memory SOMEWHERE, the GC won't reclaim it. It doesn't have to be on the stack as long as it is reachable through the stack.

I'm basically worried about this happening:

virtual DString getTitle() const {
    DString ret;
    ret.length = GetWindowTextLength(_hwnd) + 1;
    ret.ptr = (const char*)gc_malloc(ret.length, 0xA, NULL);

----gc collection on another thread----

    GetWindowText(_hwnd, (char*)ret.ptr, ret.length); // BOOM
    return ret;
}

So I guess you're saying I'm covered then? I guess there's no reason I can think of for the GC to stop scanning at the language boundary, let alone any way to actually do that efficiently.

  Thanks

Reply via email to