Replace calloc with malloc
Remove unnecessary typecast
Replace _sampgdk_intptr_t with standard ptrdiff_t