How to free memory ater use of "new" to allocate it.

Alain De Vos devosalain at ymail.com
Mon Jul 17 16:52:00 UTC 2023


This works also,


```

class C {
      int * pa;
      int [] a;
         // Constructor
         this() {writefln("Called constructor");
            pa=cast(int *)malloc(1000*int.sizeof);
            a=pa[0..1000];
           }

}

void dofun()
{
    scope x=new C;
    x.a[3]=5;
    writefln("%12x",&x);

}
int main(){
    dofun();
    dofun();
    return 0;

}

```


More information about the Digitalmars-d-learn mailing list