comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net>
Subject: Storage Pools and alloca
Date: Tue, 15 Oct 2002 15:42:39 GMT
Date: 2002-10-15T15:42:39+00:00	[thread overview]
Message-ID: <PHWq9.20400$nb.8357@nwrddc02.gnilink.net> (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?





             reply	other threads:[~2002-10-15 15:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-15 15:42 Frank J. Lhota [this message]
2002-10-15 16:32 ` Storage Pools and alloca 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
replies disabled

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