>> I'm trying to prevent it because it's dangerous

I don't see how it's dangerous. The reference count won't be incremented when you pass by reference or pass by pointer. It also won't be decremented when the function ends. So there's no danger.