View Single Post
  #20 (permalink)  
Old 01-17-2005, 08:36 PM
Maarten Wiltink
Guest
 
Posts: n/a
Default Re: Downsizing the dynamic Array

"Tom de Neef" <tdeneef@qolor.nl> wrote in message
news:41ec2803$0$6204$e4fe514c@news.xs4all.nl...

> [...] FillChar starts with:
>
> P := PChar(@Dest);
>
> (or an assembler equivalent). And that destination is (PChar(p) +
> elSize * oldLength)^ which is outside the scope of the array if it
> is newly created. Whether or not the array is recreated in a new
> memory location or kept its old location depends on the refcount.
> But I would say that there are conditions under which this first
> statement in FillChar will access an invalid address. Whether that
> will cause an AV I can not judge.


Merely computing an address you don't own won't generate any faults.
It's dereferencing it, reading or writing the memory at that address,
that does.

Groetjes,
Maarten Wiltink


Reply With Quote