comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: Q: memory management
Date: 1996/06/18
Date: 1996-06-18T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96Jun18123757@organon.com> (raw)
In-Reply-To: uvv4tod9j9e.fsf@chaq.informatik.uni-tuebingen.de


In article <uvvafy3ucoc.fsf@chaq.informatik.uni-tuebingen.de> Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes:

> 
>     Jon> the reserved word _new_ in an allocator context. [...]
> 
> I know about new.
> 
> 
>     >> I think "new Storage_Array (n)" will give me a little bit too
>     >> much storage. The array bounds need some space.
> 
>     Jon> I don't know what "storage_array" is, but don't worry about
>     Jon> the space for bounds.  It's all taken care of for you.
> 
> But I really just want a pointer to some amount of storage. I have to
> pass it to som assembly routines. This routines cannot benefit from the
> bounds in the array representatio. They would even overwrite them. And
> I have to worry about space. The here useless bounds would cost me at
> least 1MB.

I see that I have misunderstood again.  :-(  That's two strikes.  I wonder
if I've blown the last one...

If you use constrained arrays, you should there should not be any
array bounds involved in the memory allocation.  If you need to have
variable amounts you can try this:

Somewhere after you've figured out what n is:

    ...

    declare
        subtype The_Storage_Type is Storage_Array(n);
	type Storage_Ref is access The_Storage_Type;
        The_Storage : Storage_Ref := new The_Storage_Type;
    begin
        ... Stuff...
    end;

There's no reason in this context for allocating the bounds with the
actual storage for The_Storage.  Then again, I don't think there is
any guarantee either (I would be surprised if they were included, but...)

If this isn't good enough then you really will need to resort to
defining your own storage pools.  That would allow you to redefine
what happens when _new_ is used as an allocator for an access type
associated with the pool.

>     Jon> At this point don't worry about user defined storage pools
>     Jon> and allocation/deallocation.  Just use the standard
>     Jon> predefined ones.
> 
> Not possible. Perhaps I have to use malloc.

Well, this is just me bungling the answer.  In your case you may
well want to use your own storage pools.  Note that if you do, you
could use malloc as part of the implementation of them if you discovered
that there was a good reason for this.  Actually, in the case of GNAT
I think predefined _new_ turns into malloc anyway...

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





  parent reply	other threads:[~1996-06-18  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-15  0:00 Q: memory management Hannes Haug
1996-06-15  0:00 ` Jon S Anthony
1996-06-16  0:00   ` Robert Dewar
1996-06-18  0:00   ` Kent Mitchell
1996-06-15  0:00 ` Robert Dewar
1996-06-16  0:00 ` Hannes Haug
1996-06-17  0:00   ` Tucker Taft
1996-06-17  0:00   ` Hannes Haug
1996-06-18  0:00   ` Hannes Haug
1996-06-18  0:00     ` Tucker Taft
1996-06-19  0:00     ` Hannes Haug
1996-06-18  0:00 ` Jon S Anthony [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-06-19  0:00 W. Wesley Groleau (Wes)
1996-06-20  0:00 ` Hannes Haug
1996-06-20  0:00 ` Hannes Haug
1996-06-20  0:00   ` Robert Dewar
1996-06-21  0:00 ` Hannes Haug
1996-06-21  0:00   ` Robert Dewar
1996-06-25  0:00 ` Hannes Haug
1996-06-24  0:00 Q: Memory management W. Wesley Groleau (Wes)
1996-06-25  0:00 ` Hannes Haug
1996-06-25  0:00   ` Robert A Duff
1996-06-25  0:00   ` Tucker Taft
     [not found]     ` <Dtzv4J.9FL@thomsoft.com>
1996-07-17  0:00       ` Robert Dewar
1996-06-25  0:00 ` Jon S Anthony
1996-06-26  0:00   ` Robert Dewar
1996-06-27  0:00 ` Hannes Haug
     [not found] <JSA.96Jun26142033@organon.com>
1996-06-27  0:00 ` Hannes Haug
1996-06-27  0:00 ` Hannes Haug
1996-06-27  0:00   ` Robert A Duff
replies disabled

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