@@ -496,7 +496,7 @@ const HVL_SIZE = sizeof(Hvl_t) # and determine the size of the buffer needed
496496function vlenpack (v:: HDF5Vlen{T} ) where {T<: Union{HDF5Scalar,CharType} }
497497 len = length (v. data)
498498 Tp = t2p (T) # Ptr{UInt8} or Ptr{T}
499- h = Vector {Hvl_t} (undef, len)
499+ h = Vector {Hvl_t} (undef,len)
500500 for i = 1 : len
501501 h[i] = Hvl_t (convert (Csize_t, length (v. data[i])), convert (Ptr{Cvoid}, unsafe_convert (Tp, v. data[i])))
502502 end
@@ -1067,8 +1067,8 @@ name(attr::HDF5Attribute) = h5a_get_name(attr.id)
10671067function names (x:: Union{HDF5Group,HDF5File} )
10681068 checkvalid (x)
10691069 n = length (x)
1070- res = Vector {String} (undef, n)
1071- buf = Vector {UInt8} (undef, 100 )
1070+ res = Vector {String} (undef,n)
1071+ buf = Vector {UInt8} (undef,100 )
10721072 for i in 1 : n
10731073 len = h5g_get_objname_by_idx (x. id, i - 1 , buf, length (buf))
10741074 if len >= length (buf)
@@ -1083,10 +1083,10 @@ end
10831083function names (x:: HDF5Attributes )
10841084 checkvalid (x. parent)
10851085 n = length (x)
1086- res = Vector {String} (undef, n)
1086+ res = Vector {String} (undef,n)
10871087 for i in 1 : n
10881088 len = h5a_get_name_by_idx (x. parent. id, " ." , H5_INDEX_NAME, H5_ITER_INC, i- 1 , " " , 0 , H5P_DEFAULT)
1089- buf = Vector {UInt8} (undef, len+ 1 )
1089+ buf = Vector {UInt8} (undef,len+ 1 )
10901090 len = h5a_get_name_by_idx (x. parent. id, " ." , H5_INDEX_NAME, H5_ITER_INC, i- 1 , buf, len+ 1 , H5P_DEFAULT)
10911091 res[i] = String (buf[1 : len])
10921092 end
@@ -1164,7 +1164,7 @@ dataspace(attr::HDF5Attribute) = HDF5Dataspace(h5a_get_space(checkvalid(attr).id
11641164# Create a dataspace from in-memory types
11651165dataspace (x:: T ) where {T<: HDF5Scalar } = HDF5Dataspace (h5s_create (H5S_SCALAR))
11661166function _dataspace (sz:: Tuple{Vararg{Int}} , max_dims:: Union{Dims, Tuple{}} = ())
1167- dims = Vector {Hsize} (undef, length (sz))
1167+ dims = Vector {Hsize} (undef,length (sz))
11681168 any_zero = false
11691169 for i = 1 : length (sz)
11701170 dims[end - i+ 1 ] = sz[i]
@@ -1267,7 +1267,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{T}}) where {T<:HDF5Scalar}
12671267 return T[]
12681268 end
12691269 dims = size (obj)
1270- data = Array {T} (undef, dims)
1270+ data = Array {T} (undef,dims)
12711271 readarray (obj, hdf5_type_id (T), data)
12721272 data
12731273end
@@ -1279,7 +1279,7 @@ end
12791279function read (obj:: DatasetOrAttribute , :: Type{A} ) where {A<: FixedArray }
12801280 T = eltype (A)
12811281 sz = size (A)
1282- data = Array {T} (undef, sz)
1282+ data = Array {T} (undef,sz)
12831283 readarray (obj, hdf5_type_id (T), data)
12841284 data
12851285end
@@ -1290,7 +1290,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{A}}) where {A<:FixedArray}
12901290 end
12911291 sz = size (A)
12921292 dims = size (obj)
1293- data = Array {T} (undef, sz... , dims... )
1293+ data = Array {T} (undef,sz... , dims... )
12941294 nd = length (sz)
12951295 hsz = Hsize[convert (Hsize,sz[nd- i+ 1 ]) for i = 1 : nd]
12961296 memtype_id = h5t_array_create (hdf5_type_id (T), convert (Cuint, length (sz)), hsz)
@@ -1299,7 +1299,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{A}}) where {A<:FixedArray}
12991299 finally
13001300 h5t_close (memtype_id)
13011301 end
1302- ret = Array {Array{T}} (undef, dims)
1302+ ret = Array {Array{T}} (undef,dims)
13031303 # Because of garbage-collection concerns, it's best to copy the data
13041304 L = prod (sz)
13051305 for i = 1 : prod (dims)
@@ -1338,7 +1338,7 @@ function read(obj::DatasetOrAttribute, ::Type{S}) where {S<:String}
13381338 else
13391339 n = h5t_get_size (objtype. id)
13401340 pad = h5t_get_strpad (objtype. id)
1341- buf = Vector {UInt8} (undef, n)
1341+ buf = Vector {UInt8} (undef,n)
13421342 readarray (obj, objtype. id, buf)
13431343 pbuf = String (buf)
13441344 ret = unpad (pbuf, pad)
@@ -1369,10 +1369,10 @@ function read(obj::DatasetOrAttribute, ::Type{Array{S}}) where {S<:String}
13691369 return S[]
13701370 else
13711371 dspace = dataspace (obj)
1372- ret = Array {S} (undef, sz)
1372+ ret = Array {S} (undef,sz)
13731373 if isvar
13741374 # Variable-length
1375- buf = Vector {Cstring} (undef, len)
1375+ buf = Vector {Cstring} (undef,len)
13761376 h5t_set_size (memtype_id, H5T_VARIABLE)
13771377 readarray (obj, memtype_id, buf)
13781378 for i = 1 : len
@@ -1381,7 +1381,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{S}}) where {S<:String}
13811381 else
13821382 # Fixed length
13831383 ilen += 1 # for null terminator
1384- buf = Vector {UInt8} (undef, len* ilen)
1384+ buf = Vector {UInt8} (undef,len* ilen)
13851385 h5t_set_size (memtype_id, ilen)
13861386 readarray (obj, memtype_id, buf)
13871387 src = 1
@@ -1419,16 +1419,16 @@ function read_row(io::IO, membertype, membersize)
14191419 row = Any[]
14201420 for (dtype, dsize) in zip (membertype, membersize)
14211421 if dtype === String
1422- push! (row, unpad (read! (io, Vector {UInt8} (undef, dsize)), H5T_STR_NULLPAD))
1422+ push! (row, unpad (read! (io, Vector {UInt8} (undef,dsize)), H5T_STR_NULLPAD))
14231423 elseif dtype<: HDF5.FixedArray && eltype (dtype)<: HDF5BitsKind
1424- val = read! (io, Vector {eltype(dtype)} (undef, prod (size (dtype))))
1424+ val = read! (io, Vector {eltype(dtype)} (undef,prod (size (dtype))))
14251425 push! (row, reshape (val, size (dtype)))
14261426 elseif dtype<: HDF5BitsKind
14271427 push! (row, read (io, dtype))
14281428 else
14291429 # for other types, just store the raw bytes and let the user
14301430 # decide what to do
1431- push! (row, read! (io, Vector {UInt8} (undef, dsize)))
1431+ push! (row, read! (io, Vector {UInt8} (undef,dsize)))
14321432 end
14331433 end
14341434 return (row... ,)
@@ -1441,11 +1441,11 @@ function read(obj::HDF5Dataset, T::Union{Type{Array{HDF5Compound{N}}},Type{HDF5C
14411441 local membername; local membertype;
14421442 local memberoffset; local memberfiletype; local membersize;
14431443 try
1444- memberfiletype = Vector {HDF5Datatype} (undef, N)
1445- membertype = Vector {Type} (undef, N)
1446- membername = Vector {String} (undef, N)
1447- memberoffset = Vector {UInt64} (undef, N)
1448- membersize = Vector {UInt32} (undef, N)
1444+ memberfiletype = Vector {HDF5Datatype} (undef,N)
1445+ membertype = Vector {Type} (undef,N)
1446+ membername = Vector {String} (undef,N)
1447+ memberoffset = Vector {UInt64} (undef,N)
1448+ membersize = Vector {UInt32} (undef,N)
14491449 for i = 1 : N
14501450 filetype = HDF5Datatype (h5t_get_member_type (t. id, i- 1 ))
14511451 memberfiletype[i] = filetype
@@ -1464,7 +1464,7 @@ function read(obj::HDF5Dataset, T::Union{Type{Array{HDF5Compound{N}}},Type{HDF5C
14641464 h5t_insert (memtype_id, membername[i], memberoffset[i], memberfiletype[i]. id) # FIXME strings
14651465 end
14661466 # Read the raw data
1467- buf = Vector {UInt8} (undef, length (obj)* sz)
1467+ buf = Vector {UInt8} (undef,length (obj)* sz)
14681468 h5d_read (obj. id, memtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)
14691469
14701470 # Convert to the appropriate data format using iobuffer
@@ -1492,13 +1492,13 @@ function read(obj::DatasetOrAttribute, ::Type{Array{HDF5Opaque}})
14921492 objtype = datatype (obj)
14931493 try
14941494 len = h5t_get_size (objtype)
1495- buf = Vector {UInt8} (undef, prod (sz)* len)
1495+ buf = Vector {UInt8} (undef,prod (sz)* len)
14961496 tag = h5t_get_tag (objtype. id)
14971497 readarray (obj, objtype. id, buf)
14981498 finally
14991499 close (objtype)
15001500 end
1501- data = Array {Array{UInt8}} (undef, sz)
1501+ data = Array {Array{UInt8}} (undef,sz)
15021502 for i = 1 : prod (sz)
15031503 data[i] = buf[(i- 1 )* len+ 1 : i* len]
15041504 end
@@ -1508,21 +1508,21 @@ end
15081508# Read VLEN arrays and character arrays
15091509atype (:: Type{T} ) where {T<: HDF5Scalar } = Array{T}
15101510atype (:: Type{C} ) where {C<: CharType } = stringtype (C)
1511- p2a (p:: Ptr{T} , len:: Int ) where {T<: HDF5Scalar } = unsafe_wrap (Array, p, len, true )
1512- p2a (p:: Ptr{C} , len:: Int ) where {C<: CharType } = stringtype (C)(unsafe_wrap (Array, convert (Ptr{UInt8}, p), len, true ))
1511+ p2a (p:: Ptr{T} , len:: Int ) where {T<: HDF5Scalar } = unsafe_wrap (Array, p, len, own = true )
1512+ p2a (p:: Ptr{C} , len:: Int ) where {C<: CharType } = stringtype (C)(unsafe_wrap (Array, convert (Ptr{UInt8}, p), len, own = true ))
15131513t2p (:: Type{T} ) where {T<: HDF5Scalar } = Ptr{T}
15141514t2p (:: Type{C} ) where {C<: CharType } = Ptr{UInt8}
15151515function read (obj:: DatasetOrAttribute , :: Type{HDF5Vlen{T}} ) where {T<: Union{HDF5Scalar,CharType} }
15161516 local data
15171517 sz = size (obj)
15181518 len = prod (sz)
15191519 # Read the data
1520- structbuf = Vector {Hvl_t} (undef, len)
1520+ structbuf = Vector {Hvl_t} (undef,len)
15211521 memtype_id = h5t_vlen_create (hdf5_type_id (T))
15221522 readarray (obj, memtype_id, structbuf)
15231523 h5t_close (memtype_id)
15241524 # Unpack the data
1525- data = Array {atype(T)} (undef, sz)
1525+ data = Array {atype(T)} (undef,sz)
15261526 for i = 1 : len
15271527 h = structbuf[i]
15281528 data[i] = p2a (convert (Ptr{T}, h. p), Int (h. len))
@@ -1686,7 +1686,7 @@ function _getindex(dset::HDF5Dataset, T::Type, indices::Union{AbstractRange{Int}
16861686 error (" Dataset indexing (hyperslab) is available only for bits types" )
16871687 end
16881688 dsel_id = hyperslab (dset, indices... )
1689- ret = Array {T} (undef, map (length, indices))
1689+ ret = Array {T} (undef,map (length, indices))
16901690 memtype = datatype (ret)
16911691 memspace = dataspace (ret)
16921692 try
@@ -1761,9 +1761,9 @@ function hyperslab(dset::HDF5Dataset, indices::Union{AbstractRange{Int},Int}...)
17611761 error (" Wrong number of indices supplied, supplied length $(length (indices)) but expected $(n_dims) ." )
17621762 end
17631763 dsel_id = h5s_copy (dspace. id)
1764- dsel_start = Vector {Hsize} (undef, n_dims)
1765- dsel_stride = Vector {Hsize} (undef, n_dims)
1766- dsel_count = Vector {Hsize} (undef, n_dims)
1764+ dsel_start = Vector {Hsize} (undef,n_dims)
1765+ dsel_stride = Vector {Hsize} (undef,n_dims)
1766+ dsel_count = Vector {Hsize} (undef,n_dims)
17671767 for k = 1 : n_dims
17681768 index = indices[n_dims- k+ 1 ]
17691769 if isa (index, Integer)
@@ -1917,7 +1917,7 @@ end
19171917# ## Convenience wrappers ###
19181918# These supply default values where possible
19191919# See also the "special handling" section below
1920- h5a_write (attr_id:: Hid , mem_type_id:: Hid , buf:: String ) = h5a_write (attr_id, mem_type_id, Vector {UInt8} ( buf))
1920+ h5a_write (attr_id:: Hid , mem_type_id:: Hid , buf:: String ) = h5a_write (attr_id, mem_type_id, unsafe_wrap ( Vector{UInt8}, buf))
19211921function h5a_write (attr_id:: Hid , mem_type_id:: Hid , x:: T ) where {T<: HDF5Scalar }
19221922 tmp = Ref {T} (x)
19231923 h5a_write (attr_id, mem_type_id, tmp)
@@ -2211,19 +2211,19 @@ end
22112211
22122212function h5a_get_name (attr_id:: Hid )
22132213 len = h5a_get_name (attr_id, 0 , C_NULL ) # order of args differs from {f,i}_get_name
2214- buf = Vector {UInt8} (undef, len+ 1 )
2214+ buf = Vector {UInt8} (undef,len+ 1 )
22152215 h5a_get_name (attr_id, len+ 1 , buf)
22162216 String (buf[1 : len])
22172217end
22182218function h5f_get_name (loc_id:: Hid )
22192219 len = h5f_get_name (loc_id, C_NULL , 0 )
2220- buf = Vector {UInt8} (undef, len+ 1 )
2220+ buf = Vector {UInt8} (undef,len+ 1 )
22212221 h5f_get_name (loc_id, buf, len+ 1 )
22222222 String (buf[1 : len])
22232223end
22242224function h5i_get_name (loc_id:: Hid )
22252225 len = h5i_get_name (loc_id, C_NULL , 0 )
2226- buf = Vector {UInt8} (undef, len+ 1 )
2226+ buf = Vector {UInt8} (undef,len+ 1 )
22272227 h5i_get_name (loc_id, buf, len+ 1 )
22282228 String (buf[1 : len])
22292229end
@@ -2234,8 +2234,8 @@ function h5l_get_info(link_loc_id::Hid, link_name::String, lapl_id::Hid)
22342234end
22352235function h5s_get_simple_extent_dims (space_id:: Hid )
22362236 n = h5s_get_simple_extent_ndims (space_id)
2237- dims = Vector {Hsize} (undef, n)
2238- maxdims = Vector {Hsize} (undef, n)
2237+ dims = Vector {Hsize} (undef,n)
2238+ maxdims = Vector {Hsize} (undef,n)
22392239 h5s_get_simple_extent_dims (space_id, dims, maxdims)
22402240 return tuple (reverse! (dims)... ), tuple (reverse! (maxdims)... )
22412241end
@@ -2265,7 +2265,7 @@ function h5f_get_obj_ids(file_id::Hid, types::Integer)
22652265 sz = ccall ((:H5Fget_obj_count , libhdf5), Int, (Hid, UInt32),
22662266 file_id, types)
22672267 sz >= 0 || error (" error getting object count" )
2268- hids = Vector {Hid} (undef, sz)
2268+ hids = Vector {Hid} (undef,sz)
22692269 sz2 = ccall ((:H5Fget_obj_ids , libhdf5), Int, (Hid, UInt32, UInt, Ptr{Hid}),
22702270 file_id, types, sz, hids)
22712271 sz2 >= 0 || error (" error getting objects" )
@@ -2281,7 +2281,7 @@ end
22812281
22822282function hdf5array (objtype)
22832283 nd = h5t_get_array_ndims (objtype. id)
2284- dims = Vector {Hsize} (undef, nd)
2284+ dims = Vector {Hsize} (undef,nd)
22852285 h5t_get_array_dims (objtype. id, dims)
22862286 eltyp = HDF5Datatype (h5t_get_super (objtype. id))
22872287 T = hdf5_to_julia_eltype (eltyp)
@@ -2296,7 +2296,7 @@ get_create_properties(g::HDF5File) = HDF5Properties(h5f_get_create_plist(dset.id
22962296get_create_properties (g:: HDF5Attribute ) = HDF5Properties (h5a_get_create_plist (dset. id))
22972297function get_chunk (p:: HDF5Properties )
22982298 n = h5p_get_chunk (p, 0 , C_NULL )
2299- cdims = Vector {Hsize} (undef, n)
2299+ cdims = Vector {Hsize} (undef,n)
23002300 h5p_get_chunk (p, n, cdims)
23012301 tuple (convert (Array{Int}, reverse (cdims))... )
23022302end
0 commit comments