ptr: replace unnecessary unsafe code