> On Jul 18, 2018, at 4:01 PM, Ben Grasset <operato...@gmail.com> wrote:
> 
> Well, the array TFPGList uses for storage would still be allocated on the 
> heap in any case no matter what…

That’s true but the other part remains true.

Here’s from the FPC compiler itself. sc is declared at the top and ~400 lines 
later it’s freed. If they knew they were going to free at the end of the 
function anyways why did they have to go all the way to bottom to do it? if you 
want to make sure it’s freed you need to scroll through the entire 400 lines to 
confirm this.

Personally for my taste I would like to just add a little keyword to the end of 
the variable so I don’t have to worry about it later.

      var
         sc : TFPObjectList;
      begin
         old_block_type:=block_type;
         block_type:=bt_var;
         recst:=tabstractrecordsymtable(symtablestack.top);
{$if defined(powerpc) or defined(powerpc64)}
         is_first_type:=true;
{$endif powerpc or powerpc64}
         { Force an expected ID error message }
         if not (token in [_ID,_CASE,_END]) then
           consume(_ID);
         { read vars }
         sc:=TFPObjectList.create(false);

**************** 400 lines later…. ****************     

         { free the list }
         sc.free;
{$ifdef powerpc}
         is_first_type := false;
{$endif powerpc}
         block_type:=old_block_type;
        end;

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to