4 ms·
You idiot! What you wrote would have been true only if the expression were &func_table[max] - &func_table[0]. However, you make a good point: the difference b
by jongraehl 17y ago
You idiot! What you wrote would have been true only if the expression were &func_table[max] - &func_table[0].
However, you make a good point: the difference between two pointers is in multiples of the pointed-to size. It's not 11 bytes per function, but rather 11 * sizeof(pointer to function type) - probably 11 * 4 = 44 bytes. (the author is lucky that the functions are indeed laid out consecutively in memory)
When you want the difference between two pointers a and b to type T in bytes, either cast the pointers to char * before taking the pointer difference, or multiply by sizeof(T).