Change representation of dynamic arrays?

Janice Caron caron800 at googlemail.com
Sat Oct 20 00:32:57 PDT 2007


On 10/20/07, Walter Bright <newshound1 at digitalmars.com> wrote:
> >     int[] s = new int[4];
> >     int[] t = new int[1000];
> >
> > now t.begin might end up being equal to s.end. But now when we do
> >
> >     t = null;
> >
> > or t goes out of scope or we otherwise assign t, suddenly that array
> > can no longer be freed, because the end pointer of s points to it.
>
> No prob, t=null already sets both members to 0.

Both members of t, yes, but it won't stop s.end from pointing to t's
allocated memory.

That said, someone posted that you always allocate an extra byte. If
that's true, problem solved.



More information about the Digitalmars-d mailing list