Commit d45871da by Emmanuel Briot Committed by Arnaud Charlet

prj-ext.adb, [...]: Fix memory leaks.

2009-04-29  Emmanuel Briot  <briot@adacore.com>

	* prj-ext.adb, prj.adb, prj.ads: Fix memory leaks.

	* clean.adb (Ultimate_Extension_Of): removed, since duplicate of
	 Prj.Ultimate_Extending_Project_Of

From-SVN: r146940
parent 4f87ded3
2009-04-29 Emmanuel Briot <briot@adacore.com>
* prj-ext.adb, prj.adb, prj.ads: Fix memory leaks.
* clean.adb (Ultimate_Extension_Of): removed, since duplicate of
Prj.Ultimate_Extending_Project_Of
2009-04-29 Ed Schonberg <schonberg@adacore.com> 2009-04-29 Ed Schonberg <schonberg@adacore.com>
* exp_ch7.adb (Build_Final_List): If the designated type is a Taft * exp_ch7.adb (Build_Final_List): If the designated type is a Taft
......
...@@ -242,11 +242,6 @@ package body Clean is ...@@ -242,11 +242,6 @@ package body Clean is
-- Returns True iff Prj is an extension of Of_Project or if Of_Project is -- Returns True iff Prj is an extension of Of_Project or if Of_Project is
-- an extension of Prj. -- an extension of Prj.
function Ultimate_Extension_Of (Project : Project_Id) return Project_Id;
-- Returns either Project, if it is not extended by another project, or
-- the project that extends Project, directly or indirectly, and that is
-- not itself extended. Returns No_Project if Project is No_Project.
procedure Usage; procedure Usage;
-- Display the usage. If called several times, the usage is displayed only -- Display the usage. If called several times, the usage is displayed only
-- the first time. -- the first time.
...@@ -582,7 +577,7 @@ package body Clean is ...@@ -582,7 +577,7 @@ package body Clean is
loop loop
Unit := Project_Tree.Units.Table (Index); Unit := Project_Tree.Units.Table (Index);
if Ultimate_Extension_Of if Ultimate_Extending_Project_Of
(Unit.File_Names (Body_Part).Project) = Project (Unit.File_Names (Body_Part).Project) = Project
and then and then
Get_Name_String Get_Name_String
...@@ -593,7 +588,7 @@ package body Clean is ...@@ -593,7 +588,7 @@ package body Clean is
exit; exit;
end if; end if;
if Ultimate_Extension_Of if Ultimate_Extending_Project_Of
(Unit.File_Names (Specification).Project) = Project (Unit.File_Names (Specification).Project) = Project
and then and then
Get_Name_String Get_Name_String
...@@ -749,7 +744,7 @@ package body Clean is ...@@ -749,7 +744,7 @@ package body Clean is
if Unit.File_Names (Body_Part).Project /= if Unit.File_Names (Body_Part).Project /=
No_Project No_Project
then then
if Ultimate_Extension_Of if Ultimate_Extending_Project_Of
(Unit.File_Names (Body_Part).Project) = (Unit.File_Names (Body_Part).Project) =
Project Project
then then
...@@ -766,7 +761,7 @@ package body Clean is ...@@ -766,7 +761,7 @@ package body Clean is
end if; end if;
end if; end if;
elsif Ultimate_Extension_Of elsif Ultimate_Extending_Project_Of
(Unit.File_Names (Specification).Project) = (Unit.File_Names (Specification).Project) =
Project Project
then then
...@@ -1905,24 +1900,6 @@ package body Clean is ...@@ -1905,24 +1900,6 @@ package body Clean is
return Src & Tree_Suffix; return Src & Tree_Suffix;
end Tree_File_Name; end Tree_File_Name;
---------------------------
-- Ultimate_Extension_Of --
---------------------------
function Ultimate_Extension_Of (Project : Project_Id) return Project_Id is
Result : Project_Id := Project;
begin
if Project /= No_Project then
loop
exit when Result.Extended_By = No_Project;
Result := Result.Extended_By;
end loop;
end if;
return Result;
end Ultimate_Extension_Of;
----------- -----------
-- Usage -- -- Usage --
----------- -----------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2000-2008, Free Software Foundation, Inc. -- -- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -281,6 +281,8 @@ package body Prj.Ext is ...@@ -281,6 +281,8 @@ package body Prj.Ext is
".." & Directory_Separator & ".." & Directory_Separator &
".." & Directory_Separator & "gnat"); ".." & Directory_Separator & "gnat");
end if; end if;
Free (Prefix);
end; end;
end if; end if;
......
...@@ -143,7 +143,7 @@ package body Prj is ...@@ -143,7 +143,7 @@ package body Prj is
-- Table to store the path name of all the created temporary files, so that -- Table to store the path name of all the created temporary files, so that
-- they can be deleted at the end, or when the program is interrupted. -- they can be deleted at the end, or when the program is interrupted.
procedure Free (Project : in out Project_Id; Reset_Only : Boolean); procedure Free (Project : in out Project_Id);
-- Free memory allocated for Project -- Free memory allocated for Project
procedure Free_List (Languages : in out Language_Ptr); procedure Free_List (Languages : in out Language_Ptr);
...@@ -825,7 +825,7 @@ package body Prj is ...@@ -825,7 +825,7 @@ package body Prj is
-- Free -- -- Free --
---------- ----------
procedure Free (Project : in out Project_Id; Reset_Only : Boolean) is procedure Free (Project : in out Project_Id) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_Data, Project_Id); (Project_Data, Project_Id);
...@@ -835,13 +835,9 @@ package body Prj is ...@@ -835,13 +835,9 @@ package body Prj is
Free (Project.Ada_Include_Path); Free (Project.Ada_Include_Path);
Free (Project.Objects_Path); Free (Project.Objects_Path);
Free (Project.Ada_Objects_Path); Free (Project.Ada_Objects_Path);
Free_List (Project.Imported_Projects, Free_Project => False); Free_List (Project.Imported_Projects, Free_Project => False);
Free_List (Project.All_Imported_Projects, Free_Project => False); Free_List (Project.All_Imported_Projects, Free_Project => False);
Free_List (Project.Languages);
if not Reset_Only then
Free_List (Project.Languages);
end if;
Unchecked_Free (Project); Unchecked_Free (Project);
end if; end if;
...@@ -886,8 +882,7 @@ package body Prj is ...@@ -886,8 +882,7 @@ package body Prj is
procedure Free_List procedure Free_List
(List : in out Project_List; (List : in out Project_List;
Free_Project : Boolean; Free_Project : Boolean)
Reset_Only : Boolean := True)
is is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_List_Element, Project_List); (Project_List_Element, Project_List);
...@@ -898,7 +893,7 @@ package body Prj is ...@@ -898,7 +893,7 @@ package body Prj is
Tmp := List.Next; Tmp := List.Next;
if Free_Project then if Free_Project then
Free (List.Project, Reset_Only => Reset_Only); Free (List.Project);
end if; end if;
Unchecked_Free (List); Unchecked_Free (List);
...@@ -944,18 +939,19 @@ package body Prj is ...@@ -944,18 +939,19 @@ package body Prj is
Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT); Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT);
Free_List (Tree.Projects, Free_Project => True, Reset_Only => False); Free_List (Tree.Projects, Free_Project => True);
-- Private part -- Private part
Naming_Table.Free (Tree.Private_Part.Namings); Naming_Table.Free (Tree.Private_Part.Namings);
Path_File_Table.Free (Tree.Private_Part.Path_Files); Path_File_Table.Free (Tree.Private_Part.Path_Files);
Source_Path_Table.Free (Tree.Private_Part.Source_Paths); Source_Path_Table.Free (Tree.Private_Part.Source_Paths);
Object_Path_Table.Free (Tree.Private_Part.Object_Paths); Object_Path_Table.Free (Tree.Private_Part.Object_Paths);
Free (Tree.Private_Part.Ada_Path_Buffer); Free (Tree.Private_Part.Ada_Path_Buffer);
-- Naming data (nothing to free ?) -- Naming data (nothing to free ???)
null; null;
Unchecked_Free (Tree); Unchecked_Free (Tree);
...@@ -981,7 +977,7 @@ package body Prj is ...@@ -981,7 +977,7 @@ package body Prj is
Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT); Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT);
Free_List (Tree.Projects, Free_Project => True, Reset_Only => True); Free_List (Tree.Projects, Free_Project => True);
-- Private part table -- Private part table
......
...@@ -161,7 +161,7 @@ package Prj is ...@@ -161,7 +161,7 @@ package Prj is
No_Path_Information : constant Path_Information := (No_Path, No_Path); No_Path_Information : constant Path_Information := (No_Path, No_Path);
type Project_Data; type Project_Data;
type Project_Id is access Project_Data; type Project_Id is access all Project_Data;
No_Project : constant Project_Id := null; No_Project : constant Project_Id := null;
-- Id of a Project File -- Id of a Project File
...@@ -604,7 +604,7 @@ package Prj is ...@@ -604,7 +604,7 @@ package Prj is
Next => No_Language_Index); Next => No_Language_Index);
type Language_List_Element; type Language_List_Element;
type Language_List is access Language_List_Element; type Language_List is access all Language_List_Element;
type Language_List_Element is record type Language_List_Element is record
Language : Language_Ptr := No_Language_Index; Language : Language_Ptr := No_Language_Index;
Next : Language_List; Next : Language_List;
...@@ -928,7 +928,7 @@ package Prj is ...@@ -928,7 +928,7 @@ package Prj is
-- not considering Specs and Bodies. -- not considering Specs and Bodies.
type Project_List_Element; type Project_List_Element;
type Project_List is access Project_List_Element; type Project_List is access all Project_List_Element;
type Project_List_Element is record type Project_List_Element is record
Project : Project_Id := No_Project; Project : Project_Id := No_Project;
Next : Project_List := null; Next : Project_List := null;
...@@ -937,11 +937,8 @@ package Prj is ...@@ -937,11 +937,8 @@ package Prj is
procedure Free_List procedure Free_List
(List : in out Project_List; (List : in out Project_List;
Free_Project : Boolean; Free_Project : Boolean);
Reset_Only : Boolean := True);
-- Free the list of projects. If Free_Project, each project is also freed. -- Free the list of projects. If Free_Project, each project is also freed.
-- When Free_Project is True, Reset_Only indicates whether the specific
-- languages should also be freed.
type Response_File_Format is type Response_File_Format is
(None, (None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment