`free` for struct with C bindings.

Ali Çehreli acehreli at yahoo.com
Mon May 14 22:12:02 UTC 2018


On 05/14/2018 03:03 PM, Jonathan wrote:

> Do I need to call the `free` function with my D code because I need to 
> free memory that was allocated in C code?

Yes, you have to free the memory with C's free():

void main() {
     import core.stdc.stdlib;
     auto p = malloc(42);
     free(p);
}

Ali


More information about the Digitalmars-d-learn mailing list