diff --git a/src/api/helpers.jl b/src/api/helpers.jl index 42730aa26..889838703 100644 --- a/src/api/helpers.jl +++ b/src/api/helpers.jl @@ -817,6 +817,10 @@ end Retrieve a file image of the appropriate size in a `Vector{UInt8}`. """ function h5p_get_file_image(fapl_id)::Vector{UInt8} + cb = h5p_get_file_image_callbacks(fapl_id) + if cb.image_free != C_NULL + error("File image callback image_free is not C_NULL. Use the three argument method of h5p_get_file_image when setting file image callbacks.") + end buf_ptr_ref = Ref{Ptr{Nothing}}() buf_len_ref = Ref{Csize_t}(0) h5p_get_file_image(fapl_id, buf_ptr_ref, buf_len_ref) @@ -832,6 +836,26 @@ function h5p_set_file_image(fapl_id, image::Vector{UInt8}) h5p_set_file_image(fapl_id, image, length(image)) end +""" + h5p_get_file_image_callbacks(fapl_id) + +Retrieve the file image callbacks for memory operations +""" +function h5p_get_file_image_callbacks(fapl_id) + cb = H5FD_file_image_callbacks_t( + C_NULL, + C_NULL, + C_NULL, + C_NULL, + C_NULL, + C_NULL, + C_NULL) + r = Ref(cb) + h5p_get_file_image_callbacks(fapl_id, r) + return r[] +end + + # Note: The following function(s) implement direct ccalls because the binding generator # cannot (yet) do the string wrapping and memory freeing.