Now here you had me scratching my head (and searching the FAQ).
So if I read you correctly, your recommending that I define the
functions like this:
int func_lazymemory(int arg1, int arg2)
{ ... }
...and...
int func_recurs(static int arg1, static int arg2, int prev_pos)
{ ... }
...so that storage will only be allocated once for both arg1 and arg2.
Correct?
No, I just meant:
static int func_recurs(int arg1, int arg2, int prev_pos)
{ ... }
int func_lazymemory(int arg1, int arg2)
{ ... }
That way, the identifier func_recurs is only visible to other functions
in the same source file - in fact, to other functions below the first
declaration of it in that source file, which is why I moved it above
func_lazymemory.
The "static" will catch any places where you try to call func_recurs
from another source file. In effect, you're saying "func_lazymemory
is what you call when you want this functionality".
You can't declare a parameter with the "static" storage-class
specifier. (The only storage-class specifier you can use with a
parameter is "register", IIRC, and "register" is rarely useful in
modern C implementations.)
If so, this handily provides and alternate answer to question 1b from my
original post (which I just now noticed I bungled) where I was trying to
pass pointers to conserve storage:
You're probably not conserving any storage in this case. It would
depend on how your C implementation passes parameters and various
other things outside the scope of the C language, but it's unlikely
to be worth doing.
On the other hand, if func_recurs changes the values of arg1 and
arg2, and you want func_lazymemory to see those changes, then you
would want to pass their addresses so that func_recurs actually
updates the objects that func_lazymemory sees.
--
Michael Wojcik (e-mail address removed)
Unfortunately, as a software professional, tradition requires me to spend New
Years Eve drinking alone, playing video games and sobbing uncontrollably.
-- Peter Johnson