pub unsafe extern "C" fn heif_image_handle_get_context(
    handle: *const heif_image_handle
) -> *mut heif_context
Expand description

This gets the context associated with the image handle. Note that you have to release the returned context with heif_context_free() in any case.

This means: when you have several image-handles that originate from the same file and you get the context of each of them, the returned pointer may be different even though it refers to the same logical context. You have to call heif_context_free() on all those context pointers. After you freed a context pointer, you can still use the context through a different pointer that you might have acquired from elsewhere.