Signed word lengths and indexes
Adam Ruppe
destructionator at gmail.com
Fri Jun 18 15:09:42 PDT 2010
On 6/18/10, bearophile <bearophileHUGS at lycos.com> wrote:
>> static void destroy(MyString* s) {
>> free(s);
>> }
>
> Why destroy instead of ~this() ?
It allocates and deallocates the memory rather than initialize and
uninitialize the object. I don't think a destructor can free the mem
of its own object.
If I used gc.malloc or stack allocation, the destroy method shouldn't
be necessary at all, since the memory is handled automatically there.
Though, the main reason I did it this way is I was just writing in a C
style rather than a D style, so it was kinda automatic. Still, I'm
pretty sure what I'm saying here about constructor/destructor not able
to actually the memory of the object is true too.
More information about the Digitalmars-d
mailing list