Thread: Functional call != stack creation?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    Functional call != stack creation?

    I'm working on a tutorial on "vertex buffer objects" in GL. At the beginning, I try to explain why this method has obsoleted an older one (which uses way more function calls) and said, thoughtlessly:

    As we know, every function call in C/C++ requires a stack be created, then freed at the end.
    I submitted this for peer review and someone responded:

    To the best of my knowledge this isn't true. A stack frame (not stack) needs to be setup but, generally, memory allocation does not occur. It really just copies some values and moves a pointer by an offset. Function call overhead can still be an issue though.
    Thinking about this, I suppose all functions already have a stack at runtime, so it is just a matter of setting the ebp (?? or whatever) to it and copying in some values -- the memory is already allocated. Do I have this straight now?

    BUT, I still need to say something informative (and accurate) about exactly how "Function call overhead can still be an issue". I suppose this overhead is just the copying of values and not allocation of memory?
    Last edited by MK27; 12-22-2009 at 01:36 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack program
    By trishtren in forum C Programming
    Replies: 1
    Last Post: 10-01-2009, 01:47 PM
  2. Stack problem
    By silicon in forum C++ Programming
    Replies: 3
    Last Post: 11-11-2003, 04:30 PM
  3. stack implementation problem-help needed
    By sanju in forum C Programming
    Replies: 1
    Last Post: 12-10-2002, 07:29 AM
  4. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM