Opaque pointers and ccall mem. management

  1. What is the recommended julia side of C-API opaque pointer? I’d like to have a julia type for it. z1 = ccall((lib, allocateNewO), Ptr{NewO},(Uint64, ), newNumber); with NewO without structure.

  2. Can julia be convinced NOT to free all fields of a struct in GC? I have code that contains something like this

mutable struct InterpreterHooks <: GraphicsDevice
	closure::Ptr{Nothing} 
	surface_create::Ptr{Nothing} 
	surface_destroy::Ptr{Nothing}
	context_create::Ptr{Nothing} 
	context_destroy::Ptr{Nothing}
	show_page::Ptr{Nothing} 
	copy_page::Ptr{Nothing} 
	create_source_image::Ptr{Nothing} 
end

and to closure a Ptr{Nothing} is assigned, that is a pointer to a ‘context’ and it has an own finalizer. However, when GC frees an instance of InterpreterHooks it (at least that’s the story gdb+rr tells me) it frees all pointers inside it also.