To: scuffer@hups.apana.org.au Cc: linux-8086@vger.rutgers.edu From: "Joel N. Weber II" <devnull@gnu.ai.mit.edu> Date: Sun, 13 Jul 1997 20:10:11 -0400 Newsgroups: linux.dev.8086 Date: Sun, 13 Jul 1997 01:30:54 +1000 (EST) From: David Murn <scuffer@hups.apana.org.au> X-Sender: scuffer@grunge.hpy.hell cc: linux-8086@vger.rutgers.edu MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Orcpt: rfc822;linux-8086@vger.rutgers.edu Sender: owner-linux-8086@vger.rutgers.edu Precedence: bulk On Sat, 12 Jul 1997, Joel N. Weber II wrote: > In general, local variables are stored on the stack. So the stack > grows by an appropriate amount when you enter the function. Globals > are stored in a part of the program for global variables. > > malloc is only really used for dynamic allocation. Well wouldn't it make sense to allocate space on a need-to-use basis? Even if just to save a bit of space in our DS. Who knows, it might even reduce our code size, by calling malloc instead of assuming a pointer is pointing to a fixed size. You normally only allocate local variables for the duaration the function runs. It's less code to allocate all the memory for the function at one time rather than allocating it one bit at a time. And the savings in code size outwieghs any temporary savings in memory, since code to allocate memory is always taking up memory, and the storage for local variables is only allocated while the function runs.
From Unofficial Linux-8086 Mailing List Archive (ULMLA)
Maintained by Robert
Robert's Mailing List Archive Page
Archive created with babymail