diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2011-03-07 15:13:51 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2011-03-07 15:13:51 (GMT) |
commit | 6d350b411235b07f1ddbbc209204111a6ad31746 (patch) | |
tree | 398d5169df428203492e8b1767cf978281b6a149 | |
parent | 86f15d4a3326979f8a0b3898a0b7eccc453a6d38 (diff) | |
download | hdf5-6d350b411235b07f1ddbbc209204111a6ad31746.zip hdf5-6d350b411235b07f1ddbbc209204111a6ad31746.tar.gz hdf5-6d350b411235b07f1ddbbc209204111a6ad31746.tar.bz2 |
[svn-r20195] Description: Fixed memory leaks (valgrind detected) in field_info and make tables routines.
Tested: jam (gnu and intel compilers)
-rwxr-xr-x | hl/fortran/src/H5TBfc.c | 10 | ||||
-rwxr-xr-x | hl/fortran/src/H5TBff.f90 | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/hl/fortran/src/H5TBfc.c b/hl/fortran/src/H5TBfc.c index 891f387..0efc9a8 100755 --- a/hl/fortran/src/H5TBfc.c +++ b/hl/fortran/src/H5TBfc.c @@ -61,7 +61,7 @@ nh5tbmake_table_c(int_f *namelen1, size_t *c_field_offset = NULL; hid_t *c_field_types = NULL; char **c_field_names = NULL; - char *tmp = NULL; + char *tmp = NULL, *tmp_p; int_f ret_value = 0; num_elem = *nfields; @@ -95,13 +95,14 @@ nh5tbmake_table_c(int_f *namelen1, /* * move data from temorary buffer */ + tmp_p = tmp; for(i = 0; i < num_elem; i++) { if(NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1))) HGOTO_DONE(FAIL) - HDmemcpy(c_field_names[i], tmp, (size_t)char_len_field_names[i]); + HDmemcpy(c_field_names[i], tmp_p, (size_t)char_len_field_names[i]); c_field_names[i][char_len_field_names[i]] = '\0'; - tmp = tmp + *max_char_size_field_names; + tmp_p = tmp_p + *max_char_size_field_names; } /* end for */ /* @@ -122,7 +123,10 @@ done: if(c_field_names[i]) HDfree(c_field_names[i]); } /* end for */ + HDfree(c_field_names); } /* end if */ + if(tmp) + HDfree(tmp); if(c_field_offset) HDfree(c_field_offset); if(c_field_types) diff --git a/hl/fortran/src/H5TBff.f90 b/hl/fortran/src/H5TBff.f90 index 202c197..36e13f9 100755 --- a/hl/fortran/src/H5TBff.f90 +++ b/hl/fortran/src/H5TBff.f90 @@ -166,7 +166,7 @@ SUBROUTINE h5tbmake_table_f(table_title,& ! Find the size of each character string in the array DO i = 1, nfields - char_len_field_names(i) = LEN_TRIM(field_names(i)) + char_len_field_names(i) = LEN_TRIM(field_names(i)) END DO max_char_size_field_names = LEN(field_names(1)) @@ -1859,8 +1859,8 @@ SUBROUTINE h5tbget_field_info_f(loc_id,& DO i = 1, nfields namelen2(i) = LEN_TRIM(field_names(i)) END DO - maxlen = LEN(field_names(1)) + c_maxlen_out = 0 errcode = h5tbget_field_info_c(loc_id, namelen,dset_name, nfields, & field_sizes, field_offsets, type_size, namelen2, maxlen, field_names, c_maxlen_out) |