Re: AV when calling setlength on a dynamic array of boolean



On 24 Nov 2006 00:03:09 -0800, nic@xxxxxx wrote:

Hey,

In an object I use a dynamic array of booleans to store some hardware
signals.

FSignalArray: array of Boolean;

When I initialise the object it reads from a database and calculates
those booleans. The first line of the initialising is

SetLength(FSignalArray, DBSize);

and it works fine. However, when I stop running I can't do

SetLength(FSignalArray, 0);
or
FSignalArray:=nil;

If I do so, the program crashes with an invalid pointer operation or an
access violation.
If I remove that line it works fine, except that when I re-initialise
the object,

SetLength(FSignalArray, DBSize);

crashes with an access violation even though DBSize is unchanged. Still
using Delphi 6, what am I missing here?

I would guess that you have another problem and it is screwing up that
Array - SetLength is pretty reliable.

Make a copy of your App and start cutting out code.

Also turn on the bounds checking in the compiler
.



Relevant Pages