Re: Stack or Heap
- From: "bitshadow" <caroundw5h@xxxxxxxxx>
- Date: 14 Nov 2005 16:08:41 -0800
Gordon Burditt wrote
> The heap is sometimes defined as "that place from which malloc()
> allocates its memory". Standard C doesn't provide any guidance on
> this. However, in common implementations, global variables, string
> literals, code, and static variables are not considered part of
> "the heap" nor part of "the stack".
> "The stack" is a misnomer since some implementations don't have one.
> What is being referred to includes auto variables, function activation
> records (return addresses, saved registers & such) and passed
thanks for clearing that up gordon, i was coming back to ask those
questions- specifiaclly about malloc.
On reviewing my book (c primer plus 4ed) I realised it actaully spoke
about allocating structs that might be too big for the stack - though
it doesn't go too much into what that is. The solutions it presented
are making the array of structs smaller, setting my compiler stack
allowable size to something bigger or make the array static or external
- something that would not help my code.
In either case it seems best to just stick with c89 and simply use
malloc 1)because c99 still isn't widely supported and 2) as you pointed
out with VLA's it can be difficult to see if you have available memory
thank you again.
- Prev by Date: Re: Strcpy versus Strncpy in arrays
- Next by Date: Re: Using an instance of a struct as a member of that struct
- Previous by thread: Re: Stack or Heap
- Next by thread: Re: Stack or Heap