@@ -13,31 +13,34 @@ module zlib
1313
1414 interface
1515
16- subroutine inflate_C (s_deflated ,s_inflated ,deflated ,inflated ) bind(C)
17- use , intrinsic :: ISO_C_Binding, only: C_SIGNED_CHAR, C_INT64_T
16+ subroutine inflate_C (s_deflated ,s_inflated ,deflated ,inflated , stat ) bind(C)
17+ use , intrinsic :: ISO_C_Binding, only: C_SIGNED_CHAR, C_INT64_T, C_INT
1818 implicit none (type,external )
1919
2020 integer (C_INT64_T), intent (in ) :: s_deflated,s_inflated
21- integer (C_SIGNED_CHAR), dimension (s_deflated), intent (in ) :: deflated
22- integer (C_SIGNED_CHAR), dimension (s_inflated), intent (out ) :: inflated
21+ integer (C_SIGNED_CHAR), dimension (s_deflated), intent (in ) :: deflated ! ok for unsigned char
22+ integer (C_SIGNED_CHAR), dimension (s_inflated), intent (out ) :: inflated ! ok for unsigned char
23+ integer (C_INT), intent (out ) :: stat
2324 end subroutine inflate_C
2425
2526 end interface
2627
2728contains
2829
2930!- -------------------------------------------------------------------------------------------------
30- ! > @brief Inflate byte-wise representation
31+ ! > @brief Inflate byte-wise representation.
3132!- -------------------------------------------------------------------------------------------------
3233function zlib_inflate (deflated ,size_inflated )
3334
3435 integer (C_SIGNED_CHAR), dimension (:), intent (in ) :: deflated
3536 integer (pI64), intent (in ) :: size_inflated
36-
3737 integer (C_SIGNED_CHAR), dimension (size_inflated) :: zlib_inflate
3838
39+ integer (C_INT) :: stat
40+
3941
40- call inflate_C(size (deflated,kind= C_INT64_T),int (size_inflated,C_INT64_T),deflated,zlib_inflate)
42+ call inflate_C(size (deflated,kind= C_INT64_T),int (size_inflated,C_INT64_T),deflated,zlib_inflate,stat)
43+ if (stat /= 0 ) error stop ' inflate failed'
4144
4245end function zlib_inflate
4346
0 commit comments