[fpc-pascal] How to free this memory and avoid memory leak
Vincent Snijders
vsnijders at vodafonevast.nl
Thu Oct 8 16:27:13 CEST 2009
Graeme Geldenhuys schreef:
> 2009/10/8 Jonas Maebe <jonas.maebe at elis.ugent.be>:
>>> SetLength(tocarray, _Header.ntoc);
>>> p := _Data + _Header.tocoffsetsstart;
>>> Move(p, tocarray, SizeOf(tocarray));
>> This has to be
>>
>> move(p^, tocarray^, length(tocarray)*sizeof(tocarray[0]));
> ^
> This gives a compiler error. Illegal qualifier and points to the
> second ^ in that statement.
>
>
> move(p^, tocarray, _Header.ntoc*sizeof(tocarray[0]));
> Causes a segmentation fault at runtime.
>
>
> Move(p, tocarray[0], SizeOf(tocarray));
> This causes an Access Violation at runtime.
>
Move the data pointed at by p into the array elements without overwriting the
dynarray meta data structure.
Move(p^, tocarray[0], sizeof(Int32)*_Header.ntoc);
Working with pointers, if you don't get it, maybe just use a loop.
Vincent
More information about the fpc-pascal
mailing list