diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-26 07:36:23 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-26 07:36:23 +0000 |
commit | 3d461f01ca329e6486e8a9aefbe10b626eecb567 (patch) | |
tree | 3173470e6e27e281b642f203e4f297feb2f09086 /gcc | |
parent | 2253aba6069113bf4d0356a00a1eb828be807d23 (diff) | |
download | gcc-3d461f01ca329e6486e8a9aefbe10b626eecb567.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133550 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/a-suteio.adb | 10 | ||||
-rw-r--r-- | gcc/ada/a-swuwti.adb | 10 | ||||
-rw-r--r-- | gcc/ada/a-szuzti.adb | 10 |
3 files changed, 21 insertions, 9 deletions
diff --git a/gcc/ada/a-suteio.adb b/gcc/ada/a-suteio.adb index 98034e2b110..ef01398a815 100644 --- a/gcc/ada/a-suteio.adb +++ b/gcc/ada/a-suteio.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- 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 Str1 := new String'(Buffer (1 .. Last)); while Last = Buffer'Last loop 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); Str1 := Str2; end loop; @@ -73,7 +75,9 @@ package body Ada.Strings.Unbounded.Text_IO is Str1 := new String'(Buffer (1 .. Last)); while Last = Buffer'Last loop 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); Str1 := Str2; end loop; diff --git a/gcc/ada/a-swuwti.adb b/gcc/ada/a-swuwti.adb index 1e6bb2e7eab..bd06eb18c39 100644 --- a/gcc/ada/a-swuwti.adb +++ b/gcc/ada/a-swuwti.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- 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 Str1 := new Wide_String'(Buffer (1 .. Last)); while Last = Buffer'Last loop 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); Str1 := Str2; end loop; @@ -75,7 +77,9 @@ package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is Str1 := new Wide_String'(Buffer (1 .. Last)); while Last = Buffer'Last loop 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); Str1 := Str2; end loop; diff --git a/gcc/ada/a-szuzti.adb b/gcc/ada/a-szuzti.adb index 850ae78cca2..7a8a31373fe 100644 --- a/gcc/ada/a-szuzti.adb +++ b/gcc/ada/a-szuzti.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- 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 Str1 := new Wide_Wide_String'(Buffer (1 .. Last)); while Last = Buffer'Last loop 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); Str1 := Str2; end loop; @@ -76,7 +78,9 @@ package body Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO is while Last = Buffer'Last loop 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); Str1 := Str2; end loop; |