Commit 8cabd4e8 authored by Thomas White's avatar Thomas White
Browse files

hdfile_get_string_value: Handle arrays of fixed length strings

parent 1ad1c8af
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment