Freeing memory from C

Ali Çehreli acehreli at yahoo.com
Tue Dec 3 08:52:29 PST 2013


On 12/03/2013 06:45 AM, Chris wrote:

 > I became aware of uninitialized variable. I think that the latter
 > behavior is the correct one (segfault > crash). But why did it work
 > correctly in the other D program, how did the C variable get initialized?

Undefined behavior sometimes manifests itself as working correctly. :)

Regarding your original question, I suggest that the C library provides 
a function that frees the memory itself. The D code should just call 
that function with the pointer at hand.

Ali



More information about the Digitalmars-d-learn mailing list