diff --git a/sources/hash.F90 b/sources/hash.F90 index 112d2b3..f2be75f 100644 --- a/sources/hash.F90 +++ b/sources/hash.F90 @@ -195,25 +195,22 @@ module hash ! integer(kind=8) function digest(input, hash_type) result(hash) -#ifdef XXHASH use iso_c_binding, only: c_loc -#endif /* XXHASH */ implicit none integer(kind=1), dimension(:), target, intent(in) :: input integer , intent(in) :: hash_type -#ifdef XXHASH integer(kind=8) :: length -#endif /* XXHASH */ !------------------------------------------------------------------------------- ! select case(hash_type) case(hash_xxh64) #ifndef XXHASH - hash = xxh64(input) + length = size(input, kind=8) + hash = xxh64(c_loc(input), length) #else /* XXHASH */ length = size(input, kind=8) hash = xxh64_lib(c_loc(input), length, 0_8) @@ -354,24 +351,30 @@ module hash ! ! Arguments: ! -! input - the input sequence of bytes; +! buffer - the buffer pointer; +! length - the buffer length; ! !=============================================================================== ! - integer(kind=8) function xxh64(input) result(hash) + integer(kind=8) function xxh64(buffer, length) result(hash) + + use iso_c_binding, only: c_ptr, c_f_pointer implicit none - integer(kind=1), dimension(:), target, intent(in) :: input + type(c_ptr) , intent(in) :: buffer + integer(kind=8), intent(in) :: length - integer(kind=8) :: length integer(kind=8) :: remaining, offset integer(kind=8), dimension(4) :: lane, chunk + integer(kind=1), dimension(:), pointer :: input + !------------------------------------------------------------------------------- ! - length = size(input, kind=8) + call c_f_pointer(buffer, input, [ length ]) + hash = 0_8 offset = 1_8 remaining = length