Replace long with ptrdiff_t

This works better on systems where sizeof(long) == sizeof(int)