--- Comment #4 from 2010-12-10 23:16:27 PST ---
(In reply to comment #3)
> > PS: scope doesn't work on arrays. Your example code never explicitly free's 
> > the
> memory.
> That explains everything... but then, how do we delete arrays?

You can free heap allocated arrays by "delete somearray;" (deprecated in D2).

I'm not sure what's the proper way of deleting an array is. As you can see in
the implementation for "delete <array>;", it's not that trivial:
PS: That code may contain a bug. It may pass a pointer to gc_free() that is not
the start of a memory block, but gc_free() could have trouble with that and
have undefined effects on the GC heap integrity, but I digress.

When you allocate a class using scope on classes, it is normally allocated on
the stack. Doing this with arrays is hard; you need to use alloca() and turn
the resulting void* into an array...

Also, the idea with void[] was probably that it could contain *anything* that
can exist in memory. Thus the GC has to assume that it may contain pointers.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to