From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,be4b51b40516c4c6,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-24 12:36:45 PST Path: archiver1.google.com!postnews2.google.com!postnews1.google.com!not-for-mail From: prichtmyer@yahoo.com (Peter Richtmyer) Newsgroups: comp.lang.ada Subject: Allocating Memory with "new" Date: 24 Apr 2003 12:30:46 -0700 Organization: http://groups.google.com/ Message-ID: <1b585154.0304241130.35fa0a97@posting.google.com> NNTP-Posting-Host: 164.223.72.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1051212648 30395 127.0.0.1 (24 Apr 2003 19:30:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 24 Apr 2003 19:30:48 GMT Xref: archiver1.google.com comp.lang.ada:36502 Date: 2003-04-24T19:30:48+00:00 List-Id: I am stumped ... My memory allocation scheme worked OK on Gnat / Win2K, but on Sun Blade with Rational Ada it does not give me what I expected. See after program for output. I built a test program to illustrate my problem: (forgive me, it is quick and ugly) thanks Peter -------------------------------------------------------------- with system; with system.address_to_access_conversions; with Text_Io; use text_io; with unchecked_conversion; procedure Hi is first_time : boolean := true; procedure alloc (nbytes : integer) is type Mem_Block_T is array (1 .. Nbytes) of Character; package Mem_Block_Ptr_Pkg is new system.address_to_access_conversions (Mem_Block_T); Mem_Block_Ptr : Mem_Block_Ptr_Pkg.Object_Pointer := null; addr : system.address; In_Work_Area : String (1 .. 12) := " "; function Addr_to_int is new Unchecked_Conversion (system.address, integer); package data_io is new integer_io(integer); begin if first_time then first_time := false; put_line ("Mem_Block_Ptr_Pkg.Object_Pointer'size = " & Integer'image(Mem_Block_Ptr_Pkg.Object_Pointer'size)); end if; Mem_Block_Ptr := new Mem_Block_T; Addr := Mem_Block_Ptr_Pkg.to_address (Mem_Block_Ptr); Data_Io.Put (In_Work_Area, addr_to_int (addr), 16); put_line ("allocated " & In_Work_Area); end alloc; begin put_line ("system.address'size = " & Integer'image(system.address'size)); put_line ("integer'size = " & Integer'image(integer'size)); for i in 1 .. 10 loop Put ("len 1: "); alloc (1); end loop; for i in 1 .. 10 loop Put ("len 8: "); alloc (8); end loop; for i in 1 .. 50 loop Put ("len" & integer'image(i * 8) & " : "); alloc (i * 8); end loop; end Hi; -- Rational Apex Ada on SUN Blade: -- system.address'size = 32 -- integer'size = 32 -- len 1: Mem_Block_Ptr_Pkg.Object_Pointer'size = 32 -- allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 1: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8: allocated 16#F8A88# -- len 8 : allocated 16#F8A88# -- len 16 : allocated 16#F8A80# -- len 24 : allocated 16#F8A78# -- len 32 : allocated 16#F8A70# -- len 40 : allocated 16#F8A68# -- len 48 : allocated 16#F8A60# -- len 56 : allocated 16#F8A58# -- len 64 : allocated 16#F8A50# -- len 72 : allocated 16#F8A48# -- len 80 : allocated 16#F8A40# -- len 88 : allocated 16#F8A38# -- len 96 : allocated 16#F8A30# -- continues decreasing by 8 ------------------------------------------------------- -- Gnat 3.15P on Win2000 (OK) --system.address'size = 32 --integer'size = 32 --len 1: Mem_Block_Ptr_Pkg.Object_Pointer'size = 32 --allocated 16#2602450# --len 1: allocated 16#2602520# --len 1: allocated 16#2602538# --len 1: allocated 16#2602550# --len 1: allocated 16#2602568# --len 1: allocated 16#2602580# --len 1: allocated 16#2602598# --len 1: allocated 16#26025B0# --len 1: allocated 16#26025C8# --len 1: allocated 16#26025E0# --len 8: allocated 16#26025F8# --len 8: allocated 16#2602610# --len 8: allocated 16#2602628# --len 8: allocated 16#2602640# --len 8: allocated 16#2602658# --len 8: allocated 16#2602670# --len 8: allocated 16#2602688# --len 8: allocated 16#26026A0# --len 8: allocated 16#26026B8# --len 8: allocated 16#26026D0# --len 8 : allocated 16#26026E8# --len 16 : allocated 16#2602700# --len 24 : allocated 16#2602718# --len 32 : allocated 16#2602740# --len 40 : allocated 16#2602768# --len 48 : allocated 16#26027A0# --len 56 : allocated 16#26027D8# --len 64 : allocated 16#2602820# --len 72 : allocated 16#26039C8# --len 80 : allocated 16#2603A20# --len 88 : allocated 16#2603A78# --len 96 : allocated 16#2603AE0# --len 104 : allocated 16#2603B48# --len 112 : allocated 16#2603BC0# --len 120 : allocated 16#2603C38# --len 128 : allocated 16#2603CC0# --len 136 : allocated 16#2603D48#