Skip to content

Instantly share code, notes, and snippets.



Created Aug 14, 2010
What would you like to do?
#define OPTION_A (1)
#define OPTION_B (2)
#define OPTION_C (3)
#define OPTION_D (4)
#define OPTION_E (5)
void do_a(int args, char** argv){}
void do_b(int args, char** argv){}
void do_c(int args, char** argv){}
void do_d(int args, char** argv){}
void do_e(int args, char** argv){}
void some_error(int args, char** argv){}
void exec_command( int cmd, int args, char** argv ){
case OPTION_A: do_a(args, argv); break;
case OPTION_B: do_b(args, argv); break;
case OPTION_C: do_c(args, argv); break;
case OPTION_D: do_d(args, argv); break;
case OPTION_E: do_e(args, argv); break;
default: some_error(args, argv); break;
typedef void(*dispatch_t)(int, char**);
static dispatch_t d[6]={ 0, do_a, do_b, do_c, do_d, do_e };
void exec_command2( int cmd, int args, char** argv ){
d[cmd](args, argv);
int main(int args, char** argv){
int i;
int N = 1024 * 1024 * 256;
for(i=0; i<N; ++i){
exec_command2(6, args, argv);
//exec_command(6, args, argv);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment