Maybe code above works when you enforce an Garbage-collection-run ?

Code below works fine. So you cannot use "new" but must use malloc?

```

import std.stdio:writefln;
import object: destroy;
import core.memory: GC;
import core.stdc.stdlib: malloc,free;


void dofun(){
   auto pa=cast(int *)malloc(1000*int.sizeof);
   writefln("%12x",pa);
   auto a=pa[0..1000];
   free(a.ptr);
}

int main(){
    dofun();
   auto pb=cast(int *)malloc(1000*int.sizeof);
   writefln("%12x",pb);
   auto b=pb[0..1000];
   free(b.ptr);
   return 0;

}

```
  • Re: How to free ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
    • Re: How to ... Alain De Vos via Digitalmars-d-learn
      • Re: How... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: How... Steven Schveighoffer via Digitalmars-d-learn
        • Re:... Alain De Vos via Digitalmars-d-learn
          • ... Alain De Vos via Digitalmars-d-learn
            • ... Steven Schveighoffer via Digitalmars-d-learn
          • ... Steven Schveighoffer via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Alain De Vos via Digitalmars-d-learn
            • ... drug007 via Digitalmars-d-learn
              • ... Alain De Vos via Digitalmars-d-learn
                • ... drug007 via Digitalmars-d-learn
              • ... Alain De Vos via Digitalmars-d-learn
    • Re: How to ... Nick Treleaven via Digitalmars-d-learn

Reply via email to