Use PTR2IV() instead of casting a pointer to IV, to avoid warnings.

The cast to IV was added to avoid problems on platforms where pointers are
larger than longs. However, the change instead generates warnings on
platforms where IVs are larger than pointers. Instead, use the PTR2IV()
macro provided by perl.h to make everyone happy.

Also change the type of the variable on that line, because it is cast to
STRLEN the first time it is used, and then passed to a macro that assigns it
to an int regardless.