瀏覽代碼

* fixed memory leaks in compiler.

git-svn-id: trunk@5369 -
yury 18 年之前
父節點
當前提交
d8d25c2489
共有 7 個文件被更改,包括 25 次插入8 次删除
  1. 1 0
      compiler/aasmdata.pas
  2. 1 1
      compiler/cfileutils.pas
  3. 2 0
      compiler/globals.pas
  4. 3 1
      compiler/ogbase.pas
  5. 2 2
      compiler/opttail.pas
  6. 1 0
      compiler/symdef.pas
  7. 15 4
      compiler/systems/t_win.pas

+ 1 - 0
compiler/aasmdata.pas

@@ -316,6 +316,7 @@ implementation
 {$endif}
          for hal:=low(TAsmListType) to high(TAsmListType) do
            AsmLists[hal].free;
+         CurrAsmList.free;
 {$ifdef MEMDEBUG}
          memasmlists.stop;
 {$endif}

+ 1 - 1
compiler/cfileutils.pas

@@ -200,7 +200,7 @@ implementation
     constructor TDirectoryCache.create;
       begin
         inherited create;
-        FDirectories:=TFPHashObjectList.Create(false);
+        FDirectories:=TFPHashObjectList.Create(true);
       end;
 
 

+ 2 - 0
compiler/globals.pas

@@ -1293,6 +1293,8 @@ implementation
        unitsearchpath.Free;
        objectsearchpath.Free;
        includesearchpath.Free;
+       LinkLibraryAliases.Free;
+       LinkLibraryOrder.Free;
      end;
 
    procedure InitGlobals;

+ 3 - 1
compiler/ogbase.pas

@@ -601,6 +601,7 @@ implementation
       begin
         if assigned(Data) then
           Data.Free;
+        stringdispose(FCachedFullName);
         ObjRelocations.Free;
         ObjSymbolDefines.Free;
         VTRefList.Free;
@@ -1323,7 +1324,7 @@ implementation
     constructor TImportLibrary.create(AList:TFPHashObjectList;const AName:string);
       begin
         inherited create(AList,AName);
-        FImportSymbolList:=TFPHashObjectList.Create(false);
+        FImportSymbolList:=TFPHashObjectList.Create(true);
       end;
 
 
@@ -1538,6 +1539,7 @@ implementation
             objsec:=TObjSection(TmpObjSectionList[i]);
             CurrExeSec.AddObjSection(objsec);
           end;
+        TmpObjSectionList.Free;
       end;
 
 

+ 2 - 2
compiler/opttail.pas

@@ -181,8 +181,6 @@ unit opttail;
         oldnodes : tnode;
         i : longint;
       begin
-        labelnode:=clabelnode.create(cnothingnode.create);
-
         { check if the parameters actually would support tail recursion elimination }
         for i:=0 to p.paras.count-1 do
           with tparavarsym(p.paras[i]) do
@@ -190,6 +188,8 @@ unit opttail;
               ((varspez=vs_const) and
                (paramanager.push_addr_param(varspez,vardef,p.proccalloption))) then
                exit;
+
+        labelnode:=clabelnode.create(cnothingnode.create);
         if find_and_replace_tailcalls(n) then
           begin
             oldnodes:=n;

+ 1 - 0
compiler/symdef.pas

@@ -2948,6 +2948,7 @@ implementation
             dispose(inlininginfo);
             inlininginfo:=nil;
           end;
+         stringdispose(resultname);
          stringdispose(import_dll);
          stringdispose(import_name);
          if (po_msgstr in procoptions) then

+ 15 - 4
compiler/systems/t_win.pas

@@ -50,9 +50,12 @@ interface
       end;
 
       TExportLibWin=class(texportlib)
+      private
         st : string;
         EList_indexed:TFPList;
         EList_nonindexed:TFPList;
+      public
+        destructor Destroy;override;
         procedure preparelib(const s:string);override;
         procedure exportprocedure(hp : texported_item);override;
         procedure exportvar(hp : texported_item);override;
@@ -572,6 +575,14 @@ implementation
                              TExportLibWin
 *****************************************************************************}
 
+    destructor TExportLibWin.Destroy;
+      begin
+        EList_indexed.Free;
+        EList_nonindexed.Free;
+        inherited;
+      end;
+      
+    
     procedure TExportLibWin.preparelib(const s:string);
       begin
          if current_asmdata.asmlists[al_exports]=nil then
@@ -666,8 +677,8 @@ implementation
          if Gl_DoubleIndex then
            begin
              message1(parser_e_export_ordinal_double,tostr(Gl_DoubleIndexValue));
-             EList_indexed.Free;
-             EList_nonindexed.Free;
+             FreeAndNil(EList_indexed);
+             FreeAndNil(EList_nonindexed);
              exit;
            end;
 
@@ -694,10 +705,10 @@ implementation
            EList_nonindexed.Delete(ni_high);
            texported_item(EList_indexed.Items[pred(AutoIndex)]).index:=autoindex;
           end;
-         EList_nonindexed.Free;
+         FreeAndNil(EList_nonindexed);
          for i:=0 to pred(EList_indexed.Count)do
           exportfromlist(texported_item(EList_indexed.Items[i]));
-         EList_indexed.Free;
+         FreeAndNil(EList_indexed);
 
          if (target_asm.id in [as_i386_masm,as_i386_tasm,as_i386_nasmwin32]) then
           begin