aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-03-31 10:51:42 +0200
committerThomas White <taw@physics.org>2020-03-31 10:51:42 +0200
commit8cabd4e8cc04a75ae19068447a572ad157148ae0 (patch)
tree95659965f94200d4917106837cc0fb6cf6dcd856
parent1ad1c8afbf5bab7976bca860364c0553a87659c2 (diff)
hdfile_get_string_value: Handle arrays of fixed length strings
-rw-r--r--libcrystfel/src/hdf5-file.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 502ce183..c46252b5 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -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);