Made code C99 compliant by using generic function pointers instead of converting from/to void*