On 4/24/22 17:26, Salih Dincer wrote:
> first destroy() then free()...
Makes sense only if we allocated the memory.
> import object: doDestroy = destroy;
I like adding 'do' to verbs that can be confused with nouns. For
example, because 'copy' is both a noun and a verb, I think it helps when
we name a function as 'doCopy'. However, because 'destroy' is already a
verb, I would leave it alone. :)
> MEM.free(i.ptr);
> // You don't need to addrOf(cast(void*)i)
Good point about i.ptr but that free() does not or should not do
anything because it is "memory not originally allocated by this garbage
collector":
https://dlang.org/phobos/core_memory.html#.GC.free
Well... maybe it was allocated by that garbage collector and may be it
points to the beginning of an allocated block but we don't know that. I
wouldn't call free() on an array's memory.
Ali