diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2011-02-07 19:22:06 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2011-02-07 19:22:06 (GMT) |
commit | dd434c8d1f068c54b361386d1b36783c1febe604 (patch) | |
tree | 92b89cfd0144629a64987c90af8993edbbb3eb90 /tools/h5dump | |
parent | fb735d6476dc13cf0b7108fef9a9449b5e3ebe24 (diff) | |
download | hdf5-dd434c8d1f068c54b361386d1b36783c1febe604.zip hdf5-dd434c8d1f068c54b361386d1b36783c1febe604.tar.gz hdf5-dd434c8d1f068c54b361386d1b36783c1febe604.tar.bz2 |
[svn-r20056] Correct comment handling and remove cut/paste oversights
Tested: local linux
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index cc6ac01..c5af359 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2769,22 +2769,21 @@ dump_comment(hid_t obj_id) cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size); - // if the actual length of the comment is longer than cmt_bufsize, then call - // H5Oget_comment again with the correct value. - // If the call to H5Oget_comment returned an error, skip this block - if (cmt_bufsize >= 0) { - comment = (char *)HDmalloc((size_t)cmt_bufsize++); // new_size including null terminator - if(comment) + /* if the actual length of the comment is longer than cmt_bufsize, then call + * H5Oget_comment again with the correct value. + * If the call to H5Oget_comment returned an error, skip this block */ + if (cmt_bufsize > 0) { + comment = (char *)HDmalloc((size_t)cmt_bufsize); /* new_size including null terminator */ + if(comment) { cmt_bufsize = H5Oget_comment(obj_id, comment, cmt_bufsize); + if(cmt_bufsize > 0) { + indentation(indent); + printf("COMMENT \"%s\"\n", comment); + } /* end if */ + HDfree(comment); + } } - if(cmt_bufsize > 0) { - comment[cmt_bufsize] = '\0'; - indentation(indent); - printf("COMMENT \"%s\"\n", comment); - } /* end if */ - if(comment) - HDfree(comment); } /* end dump_comment() */ |