[fpc-pascal] How to free this memory and avoid memory leak

Vincent Snijders vsnijders at vodafonevast.nl
Thu Oct 8 15:58:45 CEST 2009


Graeme Geldenhuys schreef:
> Hi,
> 
> --------------------------------------
> procedure THelpFile.ReadContents;
> var
>   Topic: TTopic;
>   EntryIndex: longint;
>   pEntry: pTTOCEntryStart;
>   tocarray: array of Int32;
>   p: PByte;
> begin
>   _Topics.Capacity := _Header.ntoc;
> 
>   SetLength(tocarray, _Header.ntoc);
>   p := _Data + _Header.tocoffsetsstart;
>   Move(p, tocarray, SizeOf(tocarray));

Move(p, tocarray[0], SizeOf(tocarray));

>   for EntryIndex := 0 to _Header.ntoc-1 do
>   begin
>     pEntry := _Data + tocarray[EntryIndex];
>     Topic := TTopic.Create(_Data,
>                            _Header,
>                            _Dictionary,
>                            pEntry );
>     Topic.HelpFile := Self;
>     Topic.Index := EntryIndex;
>     _Topics.Add(Topic);
>   end;
> //  Finalize(tocarray);                        <--- doesn't work
>   Finalize(tocarray, _header.ntoc);       <--- doesn't work
>   tocarray := nil;                                  <--- doesn't work
> end;
> --------------------------------------
> 




More information about the fpc-pascal mailing list