diff options
Diffstat (limited to 'hl/src/H5TB.c')
-rw-r--r-- | hl/src/H5TB.c | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index a035319..b9cb73c 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -3213,16 +3213,12 @@ herr_t H5TBget_field_info( hid_t loc_id, size_t *field_offsets, size_t *type_size ) { - hid_t did; /* dataset ID */ - hid_t tid; /* file type ID */ - hid_t n_tid; /* native type ID */ - hid_t m_tid; /* member type ID */ - hid_t nm_tid; /* native member ID */ + hid_t did = -1; /* dataset ID */ + hid_t tid = -1; /* file type ID */ + hid_t n_tid = -1; /* native type ID */ + hid_t m_tid = -1; /* member type ID */ + hid_t nm_tid = -1; /* native member ID */ hssize_t nfields; - char *member_name; - size_t member_size; - size_t member_offset; - size_t size; hssize_t i; /* open the dataset. */ @@ -3233,62 +3229,47 @@ herr_t H5TBget_field_info( hid_t loc_id, if (( tid = H5Dget_type( did )) < 0) goto out; - if ((n_tid = H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0) + if ((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the type size */ - size = H5Tget_size( n_tid ); - - if ( type_size ) - { - *type_size = size; - } + if(type_size) + *type_size = H5Tget_size(n_tid); /* get the number of members */ if (( nfields = H5Tget_nmembers( tid )) < 0) goto out; /* iterate tru the members */ - for ( i = 0; i < nfields; i++) - { + for ( i = 0; i < nfields; i++) { /* get the member name */ - member_name = H5Tget_member_name( tid, (unsigned)i ); + if(field_names) { + char *member_name; - if (field_names ) - { - strcpy( field_names[i], member_name ); - } + member_name = H5Tget_member_name(tid, (unsigned)i); + strcpy(field_names[i], member_name); + free(member_name); + } /* end if */ /* get the member type */ - if (( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0) + if(( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0) goto out; - if ((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0) + if((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0) goto out; /* get the member size */ - member_size = H5Tget_size( nm_tid ); - - if(field_sizes ) - { - field_sizes[i] = member_size; - } + if(field_sizes) + field_sizes[i] = H5Tget_size(nm_tid); /* get the member offset */ - member_offset = H5Tget_member_offset( n_tid,(unsigned) i ); - - if(field_offsets ) - { - field_offsets[i] = member_offset; - } + if(field_offsets) + field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned) i); /* close the member types */ if (H5Tclose( m_tid ) < 0) goto out; if (H5Tclose( nm_tid ) < 0) goto out; - - free( member_name ); - } /* i */ /* close */ @@ -3308,6 +3289,8 @@ out: H5Dclose(did); H5Tclose(tid); H5Tclose(n_tid); + H5Tclose(m_tid); + H5Tclose(nm_tid); } H5E_END_TRY; return -1; |