 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Renald Yazmir Guest
|
Posted: Tue Jul 25, 2006 12:59 am Post subject: Passing structure to a fucntion by Reference vs by Value |
|
|
Hello,
Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions?
Thank you in advance
Rony |
|
| Back to top |
|
 |
Dennis Jones Guest
|
Posted: Tue Jul 25, 2006 1:56 am Post subject: Re: Passing structure to a fucntion by Reference vs by Value |
|
|
"Renald Yazmir" <renald (AT) partmaker (DOT) com> wrote in message
news:44c5268d (AT) newsgroups (DOT) borland.com...
| Quote: | Hello,
Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions?
|
I guess I'd want to know why you would prefer to avoid passing by reference
in the first place. Passing by reference (or by pointer) would almost
certainly be more efficient, not to mention less likely to have an impact on
recursive calls. However, having said that, since you're only talking about
roughly 90 bytes, you're probably not going to run into any trouble anyway.
- Dennis |
|
| Back to top |
|
 |
Ed Mulroy Guest
|
Posted: Tue Jul 25, 2006 2:35 am Post subject: Re: Passing structure to a fucntion by Reference vs by Value |
|
|
The program slows down by the amount of time it takes make a copy of the
structure on the stack.
If recursion is used then each time you recurse it again uses one
structure-sized hunk of stack and delays for however long the copy takes for
each iteration.
Using a reference is normally a better way, especially if recursion is
involved.
.. Ed
| Quote: | Renald Yazmir wrote in message
news:44c5268d (AT) newsgroups (DOT) borland.com...
Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions? |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|