diff options
Diffstat (limited to 'hl/src/H5LT.c')
-rw-r--r-- | hl/src/H5LT.c | 102 |
1 files changed, 54 insertions, 48 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index bee7612..4598dc5 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -507,9 +507,9 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, { hid_t did=-1; - hid_t sid=-1; - hid_t tid; - size_t size; + hid_t sid=-1; + hid_t tid; + size_t size; /* create a string data type */ if ( (tid = H5Tcopy( H5T_C_S1 )) < 0 ) @@ -544,7 +544,7 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, return -1; if ( H5Sclose(sid) < 0 ) return -1; - if ( H5Tclose(tid) < 0 ) + if ( H5Tclose(tid) < 0 ) goto out; return 0; @@ -860,13 +860,13 @@ herr_t H5LTread_dataset_string( hid_t loc_id, char *buf ) { hid_t did; - hid_t tid; + hid_t tid; /* Open the dataset. */ if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) return -1; - if ( (tid = H5Dget_type(did)) < 0 ) + if ( (tid = H5Dget_type(did)) < 0 ) goto out; /* Read */ @@ -876,14 +876,14 @@ herr_t H5LTread_dataset_string( hid_t loc_id, /* close */ if ( H5Dclose(did) ) goto out; - if ( H5Tclose(tid) ) + if ( H5Tclose(tid) ) return -1; return 0; out: H5Dclose( did ); - H5Tclose( tid ); + H5Tclose( tid ); return -1; } @@ -950,6 +950,7 @@ out: * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: September 4, 2001 + * Modified: February 28, 2006: checked for NULL parameters * *------------------------------------------------------------------------- */ @@ -964,36 +965,41 @@ herr_t H5LTget_dataset_info( hid_t loc_id, hid_t tid; hid_t sid; - /* Open the dataset. */ + /* open the dataset. */ if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) return -1; - /* Get an identifier for the datatype. */ + /* get an identifier for the datatype. */ tid = H5Dget_type( did ); - /* Get the class. */ - *type_class = H5Tget_class( tid ); - - /* Get the size. */ - *type_size = H5Tget_size( tid ); - - /* Get the dataspace handle */ - if ( (sid = H5Dget_space( did )) < 0 ) - goto out; + /* get the class. */ + if (type_class!=NULL) + *type_class = H5Tget_class( tid ); - /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) - goto out; + /* get the size. */ + if (type_size!=NULL) + *type_size = H5Tget_size( tid ); - /* Terminate access to the dataspace */ - if ( H5Sclose( sid ) < 0 ) - goto out; + if (dims!=NULL) + { + /* get the dataspace handle */ + if ( (sid = H5Dget_space( did )) < 0 ) + goto out; + + /* get dimensions */ + if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) + goto out; + + /* terminate access to the dataspace */ + if ( H5Sclose( sid ) < 0 ) + goto out; + } - /* Release the datatype. */ + /* release the datatype. */ if ( H5Tclose( tid ) ) return -1; - /* End access to the dataset */ + /* end access to the dataset */ if ( H5Dclose( did ) ) return -1; @@ -1121,7 +1127,7 @@ herr_t H5LTset_attribute_string( hid_t loc_id, hid_t obj_id; int has_attr; H5G_stat_t statbuf; - size_t attr_size; + size_t attr_size; /* Get the type of object */ @@ -2114,9 +2120,9 @@ print_enum(hid_t type, char* str, int indt) value = (unsigned char*)calloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { - if((name[i] = H5Tget_member_name(type, i))==NULL) + if((name[i] = H5Tget_member_name(type, i))==NULL) goto out; - if(H5Tget_member_value(type, i, value + i * super_size)<0) + if(H5Tget_member_value(type, i, value + i * super_size)<0) goto out; } @@ -2133,39 +2139,39 @@ print_enum(hid_t type, char* str, int indt) /* Print members */ for (i = 0; i < nmembs; i++) { - indentation(indt + COL, str); - nchars = sprintf(tmp_str, "\"%s\"", name[i]); + indentation(indt + COL, str); + nchars = sprintf(tmp_str, "\"%s\"", name[i]); strcat(str, tmp_str); - sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), ""); + sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), ""); strcat(str, tmp_str); - if (H5T_SGN_NONE == H5Tget_sign(native)) { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy))); + if (H5T_SGN_NONE == H5Tget_sign(native)) { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy))); strcat(str, tmp_str); - } else { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - sprintf(tmp_str,"%d", *((int*)((void *)copy))); + } else { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + sprintf(tmp_str,"%d", *((int*)((void *)copy))); strcat(str, tmp_str); - } + } - strcat(str, ";\n"); + strcat(str, ";\n"); } /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); H5Tclose(super); if (0 == nmembs) { - sprintf(tmp_str, "\n%*s <empty>", indt + 4, ""); + sprintf(tmp_str, "\n%*s <empty>", indt + 4, ""); strcat(str, tmp_str); } @@ -3534,7 +3540,7 @@ herr_t H5LT_set_attribute_string(hid_t dset_id, hid_t sid; hid_t aid; int has_attr; - size_t size; + size_t size; /* verify if the attribute already exists */ has_attr = H5LT_find_attribute(dset_id,name); |