Return to the archive index

Re: Memory allocation questions

To: scuffer@hups.apana.org.au
Cc: "ELKS List" <linux-8086@vger.rutgers.edu>
From: "Joel N. Weber II" <devnull@gnu.ai.mit.edu>
Date: 	Sun, 13 Jul 1997 03:19:41 -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

   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.

I don't think it would reduce code size.

Calling malloc has to involve at least pushing an int on the stack
and making a function call.  And then storing the result.

Note that you have to have a pointer to anything malloced.  That
pointer has to be stored somewhere.  The stack might be a good
place to store that pointer.

Also, each malloc'd area has a small header stating how long the
malloc'd object is.

Does this make sense, or do I need to restate this more persuasively?

From Unofficial Linux-8086 Mailing List Archive (ULMLA)
Maintained by Robert
Robert's Mailing List Archive Page

Archive created with babymail