From bff561063fba763a9be03fa8b4d609040f849292 Mon Sep 17 00:00:00 2001 From: Rika Ichinose Date: Sun, 27 Oct 2024 21:37:00 +0300 Subject: [PATCH] Use TFPList.FreeAndNilDisposing in four more places. --- compiler/ngenutil.pas | 6 +----- compiler/symdef.pas | 23 +++-------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/compiler/ngenutil.pas b/compiler/ngenutil.pas index eb65ce5949..90a7a209b3 100644 --- a/compiler/ngenutil.pas +++ b/compiler/ngenutil.pas @@ -1103,14 +1103,10 @@ implementation class procedure tnodeutils.release_init_final_list(list:tfplist); - var - i : longint; begin if not assigned(list) then internalerror(2017051901); - for i:=0 to list.count-1 do - dispose(pinitfinalentry(list[i])); - list.free; + TFPList.FreeAndNilDisposing(list,typeinfo(tinitfinalentry)); end; diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 4c662290dc..523df07444 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -1974,12 +1974,8 @@ implementation destructor tgenericconstraintdata.destroy; - var - i : longint; begin - for i:=0 to interfacesderef.count-1 do - dispose(pderef(interfacesderef[i])); - interfacesderef.free; + TFPList.FreeAndNilDisposing(interfacesderef,typeinfo(tderef)); interfaces.free; inherited destroy; end; @@ -2103,8 +2099,6 @@ implementation destructor tstoreddef.destroy; - var - i : longint; begin { Direct calls are not allowed, use symtable.deletedef() } if assigned(owner) then @@ -2116,10 +2110,7 @@ implementation end; rtti_attribute_list.free; genericparas.free; - if assigned(genericparaderefs) then - for i:=0 to genericparaderefs.count-1 do - dispose(pderef(genericparaderefs[i])); - genericparaderefs.free; + TFPList.FreeAndNilDisposing(genericparaderefs,typeinfo(tderef)); genconstraintdata.free; {$ifndef symansistr} stringdispose(_fullownerhierarchyname); @@ -6797,19 +6788,11 @@ implementation procedure tprocdef.freeimplprocdefinfo; - var - i : longint; begin if assigned(implprocdefinfo) then begin stringdispose(implprocdefinfo^.resultname); - if assigned(implprocdefinfo^.capturedsyms) then - begin - for i:=0 to implprocdefinfo^.capturedsyms.count-1 do - dispose(pcapturedsyminfo(implprocdefinfo^.capturedsyms[i])); - end; - implprocdefinfo^.capturedsyms.free; - implprocdefinfo^.capturedsyms:=nil; + TFPList.FreeAndNilDisposing(implprocdefinfo^.capturedsyms,typeinfo(tcapturedsyminfo)); freemem(implprocdefinfo); implprocdefinfo:=nil; end;