diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2021-08-25 23:21:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 23:21:03 (GMT) |
commit | e367c80b39529c9a863c3236e25bfb46b707b815 (patch) | |
tree | bb41c38c290d4203d557d0da60f7e61307b45a80 /hl/src | |
parent | 8f3878de399538d5848f8ba0b98aefe0c77c8a9a (diff) | |
download | hdf5-e367c80b39529c9a863c3236e25bfb46b707b815.zip hdf5-e367c80b39529c9a863c3236e25bfb46b707b815.tar.gz hdf5-e367c80b39529c9a863c3236e25bfb46b707b815.tar.bz2 |
1.10 merge clang tidy of examples and hl (#966)
* Merge of clang tidy of examples and hl from 1.12
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5LT.c | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index a804b39..c968b4c 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -2146,19 +2146,28 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str size_t size_str_to_add, size_str; if (_no_user_buf) { + char *tmp_realloc; + + if (!buf) + goto out; + /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ if (str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; - buf = (char *)HDrealloc(buf, *len); } else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; - buf = (char *)HDrealloc(buf, *len); } - } - if (!buf) - goto out; + tmp_realloc = (char *)HDrealloc(buf, *len); + if (tmp_realloc == NULL) { + HDfree(buf); + buf = NULL; + goto out; + } + else + buf = tmp_realloc; + } if (str_to_add) { /* find the size of the buffer to add */ @@ -2374,9 +2383,9 @@ out: herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { - size_t str_len = INCREMENT; - char * text_str; - herr_t ret = SUCCEED; + size_t str_len = INCREMENT; + char * text_str = NULL; + herr_t ret = SUCCEED; if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; @@ -2400,6 +2409,8 @@ H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) return ret; out: + HDfree(text_str); + return FAIL; } @@ -2779,10 +2790,14 @@ next: if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); @@ -2822,10 +2837,14 @@ next: if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); @@ -2879,10 +2898,14 @@ next: if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); stmp = NULL; @@ -2933,10 +2956,14 @@ next: if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; mtmp = (char *)HDcalloc(mlen, sizeof(char)); - if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) + if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) { + HDfree(mtmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) { + HDfree(mtmp); goto out; + } if (mtmp) HDfree(mtmp); mtmp = NULL; |