Re: Stack or Heap



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
> parameters.
>

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
or not.

thank you again.

.



Relevant Pages

  • Re: the different between aaa m1[100] and aaa *p = new [100]
    ... it has to find an appropriate block of memory. ... know what the glibc version of malloc uses, ... This means that it looks through a list of free blocks ... it of free blocks, and allocates memory. ...
    (comp.lang.cpp)
  • Re: realloc() implicit free() ?
    ... >> If we do the realloc then it means that we have allocated the ... >> extended memory for the current memory, ... >> which I extendend to realloc if compiler allocates memory ... >> what is the diffrence between the callocand malloc() ...
    (comp.lang.c)
  • Re: program is not crashing, after 10 iteration
    ... Memory allocated to your program by the system is initialized to all- ... incorrect use of malloc() / freemore obvious. ... The kernel allocator (used for memory allocated within the kernel, ... for memory the kernel allocates to programs) does something similar, ...
    (comp.std.c)
  • Re: realloc() implicit free() ?
    ... >> If we do the realloc then it means that we have allocated the ... >> extended memory for the current memory, ... >> which I extendend to realloc if compiler allocates memory ... >> what is the diffrence between the callocand malloc() ...
    (comp.lang.c)
  • Re: Framework 2.0 array redim unsatisfactory performance
    ... implementation details of Redim, Redim Preserve, and List. ... significantly higher object allocated overhead then List. ... ReDim simply allocates a new ... but I do not even attempt to test its memory ...
    (microsoft.public.dotnet.languages.vb)