diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2011-02-07 19:31:14 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2011-02-07 19:31:14 (GMT) |
commit | 5edf33586ff6cbe3fa82318c1e525bd9fee9fd35 (patch) | |
tree | 72f689ad33f803bd48f5e0c6f9d41c99edb62588 /tools/h5ls/h5ls.c | |
parent | 6c7cce106da94cc3809d6a7332f5e5ca60b85041 (diff) | |
download | hdf5-5edf33586ff6cbe3fa82318c1e525bd9fee9fd35.zip hdf5-5edf33586ff6cbe3fa82318c1e525bd9fee9fd35.tar.gz hdf5-5edf33586ff6cbe3fa82318c1e525bd9fee9fd35.tar.bz2 |
[svn-r20057] Correct comment handling and remove cut/paste oversights
merge r20056 from 1.8
Diffstat (limited to 'tools/h5ls/h5ls.c')
-rw-r--r-- | tools/h5ls/h5ls.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 051821e..420ff3f 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1815,22 +1815,21 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void /* Object comment */ cmt_bufsize = H5Oget_comment(obj, 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, comment, cmt_bufsize); + if(cmt_bufsize > 0) { + printf(" %-10s \"", "Comment:"); + display_string(stdout, comment, FALSE); + puts("\""); + } /* end if */ + HDfree(comment); + } } - if(cmt_bufsize > 0) { - comment[cmt_bufsize] = '\0'; - printf(" %-10s \"", "Comment:"); - display_string(stdout, comment, FALSE); - puts("\""); - } /* end if */ - if(comment) - HDfree(comment); } /* end if */ /* Detailed list for object */ |