comp.lang.ada
 help / color / mirror / Atom feed
* Q: Creating my own storage pools
@ 2003-01-21  3:56 Victor Porton
  2003-01-21 15:10 ` Stephen Leake
  2003-01-21 19:33 ` Robert A Duff
  0 siblings, 2 replies; 3+ messages in thread
From: Victor Porton @ 2003-01-21  3:56 UTC (permalink / raw)


13.11.20. "The effect of calling Allocate and Deallocate for a standard
storage pool directly (rather than implicitly via an allocator or an
instance of Unchecked_Deallocation) is unspecified."

I want to use the standard storage pool for allocating memory for my
own portable storage pool. But how to allocate from the standard pool
the given number of storage elements? Should I use packed arrays?

Also how to deal with alignment of the allocated memory?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Q: Creating my own storage pools
  2003-01-21  3:56 Q: Creating my own storage pools Victor Porton
@ 2003-01-21 15:10 ` Stephen Leake
  2003-01-21 19:33 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2003-01-21 15:10 UTC (permalink / raw)


porton@ex-code.com (Victor Porton) writes:

> 13.11.20. "The effect of calling Allocate and Deallocate for a standard
> storage pool directly (rather than implicitly via an allocator or an
> instance of Unchecked_Deallocation) is unspecified."
> 
> I want to use the standard storage pool for allocating memory for my
> own portable storage pool. But how to allocate from the standard pool
> the given number of storage elements? 

My_Storage := new System.Storage_Elements.Storage_Array (size);

> Should I use packed arrays?

Probably not. You want the storage pool to be efficient in time;
forcing the compiler to pack an array that is not "naturally" packed
makes it inefficient in time.

However, on any reasonable system,
System.Storage_Elements.Storage_Array is "naturally" packed.

> Also how to deal with alignment of the allocated memory?

Make sure the pointer you return is aligned as required. This means
you will have small spaces of unused storage in your pool

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Q: Creating my own storage pools
  2003-01-21  3:56 Q: Creating my own storage pools Victor Porton
  2003-01-21 15:10 ` Stephen Leake
@ 2003-01-21 19:33 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 2003-01-21 19:33 UTC (permalink / raw)


porton@ex-code.com (Victor Porton) writes:

> 13.11.20. "The effect of calling Allocate and Deallocate for a standard
> storage pool directly (rather than implicitly via an allocator or an
> instance of Unchecked_Deallocation) is unspecified."
> 
> I want to use the standard storage pool for allocating memory for my
> own portable storage pool. But how to allocate from the standard pool
> the given number of storage elements?

Use "new" on a type with no "for T'Storage_Pool use...".

>... Should I use packed arrays?

I don't think packing has anything to do with it.

> Also how to deal with alignment of the allocated memory?

Say "for T'Alignment use ..." on the type that is being new-ed.
This is probably an array of bytes or array of words or some
such thing, and your pool is allocating individual pieces of those
chunks.

- Bob



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-21 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-21  3:56 Q: Creating my own storage pools Victor Porton
2003-01-21 15:10 ` Stephen Leake
2003-01-21 19:33 ` Robert A Duff

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