TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Paul Edwards
date: 1996-08-20 22:56:18
subject: Passing a var.

FA> Does passing a pointer to a function effect performance, as opposed to
FA> having the contents of said pointer global or local ? 

IMO, having a local function will ALWAYS be faster than or equal to the
speed of a global function which will ALWAYS be faster than a pointer to a
function.  Basically, having a local (and preferably static) function means
AT COMPILE TIME, the compiler has ALL the information available to it at
compile time, and can maybe even implement the function as inline code, and
then remove the function altogether!

With a global function (perhaps in another source file), AT LINK TIME, the
linker is able to resolve the external reference, and possibly insert a
direct call to that address.

With a function pointer, AT RUN TIME, the code must be able to read the
function pointer out of a variable, and then do whatever is required on
that platform to execute a function.

FA> Also, does re-entrancy mean, that one can have multiple instances of a 
FA> function/program ?  Yep, still trying to learn the right terminology.

Reentrancy generally means that two processes can run the same program, and
only one copy of the executable code is actually stored in the computer's
memory.  Of course each process needs its own data area.

Another meaning of reentrancy is that in two places in your code, you can
call a particular function, independently of someone else calling the
function.  In the C library, strtok() is not reentrant, because it
(basically) uses static storage, and maintains it between calls, so only
one person can execute it at a time.  BFN.  Paul. 
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.