comp.lang.ada
 help / color / mirror / Atom feed
From: "bubble" <bubble@riskm.com.tw>
Subject: function "&" for strings type cause memory problem.
Date: Thu, 10 Nov 2005 16:25:09 +0800
Date: 2005-11-10T16:25:09+08:00	[thread overview]
Message-ID: <dkv059$hit$1@netnews.hinet.net> (raw)

dear all:
I have a project need mix 2 language (VB and Ada).


VB do GUI  and monitor the real time quote then trigger kernel work.
Ada with gnatcom to do kernel work (financial model pricing).

in the project, a code snip will raise storage_error excpeiton because I 
combine 2  BIG string to 1 string.

I test the code snip and I get some problem in the statement, Nstring2 := 
new String'(String1 & String2) .

if I compiling the code to stand alone execute file and enable pragma 
Linker_Options ("-Wl,--stack=0x10000000");
It both  passed.
if I compiling it to DLL ,it pass test 1 and fail in test2

                                                    Test 1              | 
Test 2
-----------------------------------------------------------------------------------------------
.exe with Linker_Options       |     Pass 
Pass
.exe without Liner_Options    |     Pass                                Fail
.dll with Linker_Options         |    Pass 
Fail
.dll without Linker_Options    |    Pass 
Fail

Test Environment
----------------------------------------------------------------------------------------------
OS:Windows XP.
memory :640 MB.
VB: Microsoft Visual Basic 6
gnatcom version: 1.4
ada compiler: Gnat GPL 2005



I guess functin "&" for string type may have potential  problem in gnat 
windows editions.
does any body know the problem and give me some suggestion.
thanks








Test Code
--------------------------------------------------------------------------------------------------
with Ada.Text_IO;
Use Ada.Text_Io;

procedure test is
   --pragma Linker_Options ("-Wl,--stack=0x10000000");
   type access_string is access all String;
   String1 : String := (1 .. 10_000_000 => 'a');
   String2 : String := (1 .. 10_000_000 => 'b');

begin
   declare
      nString : access_string := null;
   begin
      nString:= new String (1 .. String1'Length + String2'Length);
      nString.all (String1'First .. String2'Last) := String1;
      nString.all ( String1'First + String2'First.. String1'First + 
String2'Last):= String2;
      Put_Line("Test 1 Passed");
   Exception
      When Others=>
         Put_Line("Test 1 Fail");
   end;
   declare
      Nstring2 : access_string := null;
   begin
      Nstring2 := new String'(String1 & String2);
      Put_Line("Test 2 Passed ");
   exception
      when others =>
         Ada.Text_IO.Put_Line ("Test 2 Fail");
   end;
end test; 





             reply	other threads:[~2005-11-10  8:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-10  8:25 bubble [this message]
2005-11-10  9:01 ` function "&" for strings type cause memory problem Alex R. Mosteo
2005-11-10  9:23 ` Dmitry A. Kazakov
2005-11-10 18:04 ` tmoran
2005-11-10 20:45 ` Jeffrey R. Carter
2005-11-11  8:25 ` bubble
2005-11-11  9:43   ` Dmitry A. Kazakov
2005-11-11 11:55     ` bubble
2005-11-11 13:45       ` Dmitry A. Kazakov
2005-12-01  0:18         ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox