Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Oleksii Turkot
CrystFEL
Commits
8cabd4e8
Commit
8cabd4e8
authored
Mar 31, 2020
by
Thomas White
Browse files
hdfile_get_string_value: Handle arrays of fixed length strings
parent
1ad1c8af
Changes
1
Hide whitespace changes
Inline
Side-by-side
libcrystfel/src/hdf5-file.c
View file @
8cabd4e8
...
...
@@ -2124,7 +2124,6 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name,
if
(
class
==
H5T_STRING
)
{
herr_t
r
;
hid_t
sh
;
htri_t
v
;
v
=
H5Tis_variable_str
(
type
);
...
...
@@ -2134,6 +2133,8 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name,
return
"WTF?"
;
}
else
if
(
v
>
0
)
{
/* Variable length string */
hid_t
memspace
,
filespace
;
if
(
make_dataspaces
(
dh
,
ev
,
&
memspace
,
&
filespace
)
)
{
...
...
@@ -2157,21 +2158,21 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name,
}
else
{
/*
v == 0
*/
/*
Fixed-length string
*/
size
=
H5Tget_size
(
type
);
tmp
=
malloc
(
size
+
1
);
hid_t
memspace
,
filespace
;
sh
=
H5Dget_space
(
dh
);
if
(
H5Sget_simple_extent_ndims
(
sh
)
)
{
if
(
make_dataspaces
(
dh
,
ev
,
&
memspace
,
&
filespace
)
)
{
H5Tclose
(
type
);
free
(
subst_name
);
return
strdup
(
"[
non-scalar string
]"
);
return
strdup
(
"[
couldn't make dataspaces
]"
);
}
sh
=
H5Screate
(
H5S_SCALAR
);
r
=
H5Dread
(
dh
,
type
,
sh
,
H5S_ALL
,
H5P_DEFAULT
,
tmp
);
H5Sclose
(
sh
);
size
=
H5Tget_size
(
type
);
tmp
=
malloc
(
size
+
1
);
r
=
H5Dread
(
dh
,
type
,
memspace
,
filespace
,
H5P_DEFAULT
,
tmp
);
if
(
r
<
0
)
{
free
(
tmp
);
free
(
subst_name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment