back to arays

Max Samuha maxter at i.com.ua_spamless
Wed May 17 00:13:55 PDT 2006


There's one more question about arrays.

>From D specs:

>A pointer to the start of a garbage collected object need not be maintained if a pointer to the interior of the object exists.
>char[] p = new char[10];
>char[] q = p[3..6];
>// q is enough to hold on to the object, don't need to keep
>// p as well.

If the garbage collector moves data referenced by p, i guess all
pointers to slices of p will be updated correctly.  

What if i set p to null or p goes out of scope and q is still
reachable, will the memory (before q.ptr and after q.ptr + q.length -
1) that was pointed to by p be reclaimed by the garbage collector? 




More information about the Digitalmars-d-learn mailing list