Re: alloca / _alloca / dynamic stack memory



"Michael Crawley" <Michael Crawley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:3EFCAF3F-7BF3-4641-AE18-0488FB97D545@xxxxxxxxxxxxx
The
most popular is alloca(size_t), which is not found in the default
libraries of many C++ compilers. If I am not mistaken, I do not
believe VS 2003 had it, but VS 2005 has it.

_alloca (with leading underscore) has been there since at least VC6.

It is my understanding
that developers can invoke alloca(size_t) to allocate memory on the
stack and pass the allocated memory reference as a parameter into
placement new.

Why not just declare a local variable? It would go on the stack, and
would be constructed and destroyed automatically.

What exactly are you trying to achieve? I'm missing the point of the
exercise.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Windows XP SP2 Memory Fragmentation
    ... Try to reduce the number of libraries the executable does link to. ... Maybe some libraries which are included allocate memory in their ... adversially divides the address-space. ... EXE under http://520032173347.bei.t-online.de/cas/. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: prefast "stack hog" warning for newed array
    ... Consider moving some data to heap. ... > Does not new allocate memory from the heap? ... > the stack then wouldn't a new'd object be lost when the function ... new allocates from the heap and this warning is bogus. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: obj function hello()
    ... Roland Pibinger wrote: ... what else would you use to allocate memory than one of the ... In standard C there is no such thing as a stack, ... -- Francis Crick, co-discover of DNA ...
    (comp.lang.c)
  • Re: stack questions
    ... platform specific caveat to this since the documentation does not suggest ... Unless you are overflowing the stack, ... allocate memory outside the stack space? ... Yes, malloc allocates memory on the heap, not the stack (this is exactly how ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: C++ Question
    ... (ImageConsultant) ... > Q 1 Write a class which always allocate memory to its objects from heap only? ... If you feel the class has too big a sizeofto put on the stack then ...
    (comp.lang.cpp)

Loading