| ??? 11/08/07 18:09 Read: times |
#146788 - Heads up Responding to: ???'s previous message |
The following bit of code is from the example referenced here.
void newvswitch(int select)
{
void (*vfunc[4])(void) = { vfunc1, vfunc2, vfunc3, vfunc4 };
if (select > 0 && select < 5)
(*vfunc[select-1])();
}
While this will work just fine, it's inefficient for no good reason because the table of function pointers, vfunc[], is declared as an automatic variable within the function newvswitch(). I'm pretty sure that means the entire table has to be initialized every time the function is called. True?
Better I think to explicitly declare the table static, or to move its declaration outside the function where it will be static by default. -- Russ |
| Topic | Author | Date |
| C : pointers of function und pointers of pointers | 01/01/70 00:00 | |
| Function pointers and stuff | 01/01/70 00:00 | |
| Parameter passing in C | 01/01/70 00:00 | |
| C FAQ | 01/01/70 00:00 | |
| Function pointer demo | 01/01/70 00:00 | |
| Heads up | 01/01/70 00:00 | |
| True | 01/01/70 00:00 | |
| I use function pointers all the time | 01/01/70 00:00 | |
| void-void function pointers need not be slow | 01/01/70 00:00 | |
| correct, with a caveat | 01/01/70 00:00 | |
thank you all. | 01/01/70 00:00 |



