A bug in my code
Manfred_Nowak
svv1999 at hotmail.com
Sat Sep 6 19:58:13 PDT 2008
bearophile wrote:
> > this.list_tail.next = new_block;
> So that code looks correct to me.
Sorrily it might be correct only at the surface. In the deeper grounds
your coding might be lead by some wrong assumptions on the semantics of
the interface to the GC.
You are setting the attribute of `hasNoPointers' for each and every
memory block you `malloc'. But this is not true, because with the
assignment above you are introducing a pointer into that area, without
calling `hasPointers'.
This means that on the nextrun of `FullCollect' close to no elements of
the list are referenced anymore: they all get collected, except `head'
and `tail' ofcourse.
You can see this by introducing a simple printout:
| int ncopy = min(aux_ptr.len, this.total_len - pos);
| writefln( ncopy);
which will printout the lines
| 4
| 69996
| 0
| .....
for the second run of `st.toarray'.
-manfred
--
If life is going to exist in this Universe, then the one thing it
cannot afford to have is a sense of proportion. (Douglas Adams)
More information about the Digitalmars-d-learn
mailing list