On Tuesday, 11 June 2013 at 03:08:36 UTC, H. S. Teoh wrote:
Or is this just a quick-n-dirty way to get a no-GC environment without needing hack druntime?
Yea, that's the idea here. Like Simen said, if these were errors, your program wouldn't even start, so noop is better. Though gc_init should call thread_init, which I didn't do here. Without that call, stack traces on exceptions will segfault on linux.
So extern (C) void thread_init(); extern(C) void gc_init() { thread_init(); } will be better than doing nothing.
Hmm. What if the user code instantiates classes? Will they leak memory then?
Unless you free() it! But like with the stub functions, druntime uses new in the startup code, so if this was removed entirely, you wouldn't get far. Exceptions are also useful and you gotta new them.
Though I suppose the point is really just to find *hidden* allocations, and 'new' is a pretty blatant use of the GC.
Exactly, it isn't that hard to match new with free since it is clear that you used it and can follow the object's lifetime manually. A hidden allocation though, even though you might be able to free it, can slip past you.
