Note, this, to me, seems odd. Of course this is not the full case, but you are not affecting anything except for the value of the local `ptr`. So I would be concerned this may not be what you want (if you are looking to affect something outside the callback).
Yeah, I went overboard in reducing my scenario :( The actual function bar also receives by ref its pointer.