diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-01-26 13:40:56 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-01-26 13:40:56 +1300 |
commit | 368de8d512c6faa0cedd8de06f5e1885a8f22d10 (patch) | |
tree | f146fbe522f62c751b6da224f0268c26329bd60f | |
parent | Refactor targets into list (diff) | |
download | funcptr-368de8d512c6faa0cedd8de06f5e1885a8f22d10.tar.gz funcptr-368de8d512c6faa0cedd8de06f5e1885a8f22d10.zip |
Move fpv to be static file var
-rw-r--r-- | funcptr.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -18,6 +18,8 @@ int half(int i) { return i / 2; } +static int (*fpv[])(int) = {doub, trip, half, NULL}; + void fpv_exec(int (**fpv)(int), int n) { int i; for (i = 0; *(fpv + i) != NULL; i++) { @@ -26,14 +28,6 @@ void fpv_exec(int (**fpv)(int), int n) { } int main(int argc, char **argv) { - int (**fpv)(int); - fpv = calloc(4, sizeof(int (*)(int))); - - fpv[0] = doub; - fpv[1] = trip; - fpv[2] = half; - fpv[3] = NULL; - for (argv++, argc--; argc; argv++, argc--) { fpv_exec(fpv, atoi(*argv)); } |