I’m using ccall to access a C library that has its own memory management. For the constructor and destructor calls, it expects a void**. I thought it would be most natural to create a Ptr{Cvoid} in Julia, then pass a Ref of that to the ccall. However, I get this unexpected behavior:
What you want to do is impossible. If ptr is C_NULL, the only way to change that is by assigning to ptr, i.e. ptr = .... There’s absolutely no exception to this rule, you cannot implicitly modify what a variable is bound to ever. Applying to immutable types (like Ptr) this means that without reassignment it’ll always be the same object witht he same content in that variable.
You already have the closest you can get in julia with your C code, which is to just use ptrptr[] instead.