What I'm trying to do is have some specific classes be pool-allocated though, not completely circumvent the GC.

On Sunday, 26 October 2014 at 08:02:25 UTC, Mike wrote:
On Sunday, 26 October 2014 at 07:08:21 UTC, Mike wrote:

I tried this on my Linux desktop, and while everything compiled and linked without errors, it resulted in a segmentation fault at runtime. But where I have failed, others may succeed. I tested with LDC and GDC, but not DMD.

It does work, but for some reason if I replace the printf statement below with D's writeln, I get a segmentation fault. I don't know why. Anywhere here's a trivial example to illustrate the idea.

module main;

import std.stdio;
import core.stdc.stdio;

extern (C) Object __wrap__d_newclass(const ClassInfo ci)
{
    printf("You haven't provided any custom allocation yet!\n");
    while(true) {}
    return null;
}

void main(string[] args)
{

}

Compile with:
gdc -Wl,-wrap,_d_newclass main.d

You'll see it output the string before it even reaches main because the runtime initialization seems to allocate a few things. But, you get the idea. destroy is just a template, however, so it will need a different method.

Mike

Reply via email to