Commit cfd71216 by Vincent Celier Committed by Arnaud Charlet

a-szuzti.adb, [...] (functions Get_Line): Improve memory usage to avoid use of stack.

2008-03-26  Vincent Celier  <celier@adacore.com>

	* a-szuzti.adb, a-swuwti.adb, a-suteio.adb (functions Get_Line):
	Improve memory usage to avoid use of stack.

From-SVN: r133550
parent 1b24ada5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-2005, Free Software Foundation, Inc. -- -- Copyright (C) 1997-2007, 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- --
...@@ -51,7 +51,9 @@ package body Ada.Strings.Unbounded.Text_IO is ...@@ -51,7 +51,9 @@ package body Ada.Strings.Unbounded.Text_IO is
Str1 := new String'(Buffer (1 .. Last)); Str1 := new String'(Buffer (1 .. Last));
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (Buffer, Last); Get_Line (Buffer, Last);
Str2 := new String'(Str1.all & Buffer (1 .. Last)); Str2 := new String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
...@@ -73,7 +75,9 @@ package body Ada.Strings.Unbounded.Text_IO is ...@@ -73,7 +75,9 @@ package body Ada.Strings.Unbounded.Text_IO is
Str1 := new String'(Buffer (1 .. Last)); Str1 := new String'(Buffer (1 .. Last));
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (File, Buffer, Last); Get_Line (File, Buffer, Last);
Str2 := new String'(Str1.all & Buffer (1 .. Last)); Str2 := new String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-2005, Free Software Foundation, Inc. -- -- Copyright (C) 1997-2007, 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- --
...@@ -51,7 +51,9 @@ package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is ...@@ -51,7 +51,9 @@ package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is
Str1 := new Wide_String'(Buffer (1 .. Last)); Str1 := new Wide_String'(Buffer (1 .. Last));
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (Buffer, Last); Get_Line (Buffer, Last);
Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last)); Str2 := new Wide_String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
...@@ -75,7 +77,9 @@ package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is ...@@ -75,7 +77,9 @@ package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is
Str1 := new Wide_String'(Buffer (1 .. Last)); Str1 := new Wide_String'(Buffer (1 .. Last));
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (File, Buffer, Last); Get_Line (File, Buffer, Last);
Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last)); Str2 := new Wide_String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-2005, Free Software Foundation, Inc. -- -- Copyright (C) 1997-2007, 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- --
...@@ -51,7 +51,9 @@ package body Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO is ...@@ -51,7 +51,9 @@ package body Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO is
Str1 := new Wide_Wide_String'(Buffer (1 .. Last)); Str1 := new Wide_Wide_String'(Buffer (1 .. Last));
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (Buffer, Last); Get_Line (Buffer, Last);
Str2 := new Wide_Wide_String'(Str1.all & Buffer (1 .. Last)); Str2 := new Wide_Wide_String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
...@@ -76,7 +78,9 @@ package body Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO is ...@@ -76,7 +78,9 @@ package body Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO is
while Last = Buffer'Last loop while Last = Buffer'Last loop
Get_Line (File, Buffer, Last); Get_Line (File, Buffer, Last);
Str2 := new Wide_Wide_String'(Str1.all & Buffer (1 .. Last)); Str2 := new Wide_Wide_String (1 .. Str1'Last + Last);
Str2 (Str1'Range) := Str1.all;
Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last);
Free (Str1); Free (Str1);
Str1 := Str2; Str1 := Str2;
end loop; end loop;
......
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