comp.lang.ada
 help / color / mirror / Atom feed
* Storage Pools and alloca
@ 2002-10-15 15:42 Frank J. Lhota
  2002-10-15 16:32 ` Matthew Heaney
  2002-10-15 19:14 ` Robert A Duff
  0 siblings, 2 replies; 12+ messages in thread
From: Frank J. Lhota @ 2002-10-15 15:42 UTC (permalink / raw)


C / C++ sometimes cut down on the hassles of memory management by using the
"alloca" function. The "alloca" function, which is frequently implicit,
allocates storage from the stack. Since memory allocated by "alloca" is on
the stack, it is reclaimed automatically as soon as the function that
allocated this memory returns.

AFAIK, the "alloca" functionality could be added to Ada using the storage
pool facility. One could derive a type from
System.Storage_Pools.Root_Storage_Pool and write the required subprograms
for this type as follows:

    - The Allocate procedure would allocate memory from the stack, sort of
like the C "alloca" function;
    - The Deallocate procedure should do nothing; and
    - The Storage_Size should return the amount of space left on the stack.

Of course, this is highly platform dependant, and would often require
machine code insertions.

Questions:

    1) Does any Ada compiler provide this type of storage pool?
    2) If this type of storage pool was available, would you find it useful?
    3) Would an "alloca" storage pool be a worthwhile addition to Ada 0x?





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

end of thread, other threads:[~2002-10-19 20:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15 15:42 Storage Pools and alloca Frank J. Lhota
2002-10-15 16:32 ` Matthew Heaney
2002-10-15 17:26   ` Frank J. Lhota
2002-10-15 18:02     ` David C. Hoos
2002-10-15 19:14 ` Robert A Duff
2002-10-15 20:23   ` Frank J. Lhota
2002-10-15 20:54     ` Robert A Duff
2002-10-16 13:42       ` Frank J. Lhota
2002-10-16  7:32     ` Eric G. Miller
2002-10-16 13:42       ` Frank J. Lhota
2002-10-19 20:30         ` Eric G. Miller
2002-10-16  5:20   ` Simon Wright

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