Skip to content

Commit

Permalink
Check for file image callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Sep 1, 2023
1 parent c6e3ea3 commit 07f80f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/api/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.

Expand Down

0 comments on commit 07f80f1

Please sign in to comment.