Shared library string safety?
Mineko
uminekorox at gmail.com
Mon Jan 13 23:44:20 PST 2014
On Tuesday, 14 January 2014 at 07:23:52 UTC, evilrat wrote:
>
> the reason string.dup worked is due to GC on app side, right
> after the moment your lib receive the original string it is may
> be marked by GC for collection, so you need to save a copy on
> lib side. but using the proxies it should work without copying.
>
>
> for windows here is the topic about this
> http://dlang.org/dll.html
>
> for *nix platforms it should be the same.
>
> in short(pseudocode):
> ==========================
> app.d
>
> extern(C) void* gc_getProxy();
>
> void main()
> {
> loadlib();
> initLib( gc_getProxy() );
> ... do something ...
> libFinalize();
> }
>
> ------------------
> lib.d
>
> extern (C)
> {
> void gc_setProxy(void* p);
> void gc_clrProxy();
> }
>
> export void initLib(void* gc)
> {
> gc_setProxy(gc);
> }
>
> export void libFinalize()
> {
> gc_clrProxy();
> }
> ==========================
>
> as i said i don't know about current status of shared libs, but
> there was some progress on linux and Windows, and
> unfortunatelly not OS X...
I see, I'll have to look more into that, on a slightly unrelated
note, any idea what's going on with glfwCreateWindow, it keeps
wanting to be null while it's supposed to be an adddress.
this.get = glfwCreateWindow(settings.width, settings.height,
toStringz(settings.title), this.monitor, this.share);
writeln(this.get);
That writeln will give me null, is it related to all this stuff?
More information about the Digitalmars-d-learn
mailing list