mem: free the allocated memory
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
---
gas/config/tc-bfin.c | 4 ++++
gprofng/examples/mxv-pthreads/src/main.c | 1 +
2 files changed, 5 insertions(+)
Comments
On 19.06.2024 07:28, zhangxianting wrote:
> --- a/gas/config/tc-bfin.c
> +++ b/gas/config/tc-bfin.c
> @@ -1884,6 +1884,8 @@ bfin_gen_loop (Expr_Node *exp, REG_T reg, int rop, REG_T preg)
> if (!S_IS_LOCAL (sym) || (S_IS_LOCAL (sym) && !symbol_used_p (sym)))
> symbol_remove (sym, &symbol_rootP, &symbol_lastP);
>
> + free(lbeginsym);
> + free(lendsym);
> return bfin_gen_loopsetup (lbegin, reg, rop, lend, preg);
> }
It doesn't look to me as if these were correct. The pointers are stored
in the nodes created by Expr_Node_Create(), and hence continue to be
valid at least up into bfin_gen_loopsetup(). This, imo, is the kind of
change that can't come without description, justifying why the change
is safe to make.
> @@ -1919,6 +1921,8 @@ bfin_loop_beginend (Expr_Node *exp, int begin)
> Adjust label address. */
> if (!begin)
> *symbol_X_add_number (linelabel) -= last_insn_size;
> +
> + free(label_name);
> }
This one indeed looks as if it was wanted. Note however that GNU style
demands a blank ahead of the opening parenthesis.
> --- a/gprofng/examples/mxv-pthreads/src/main.c
> +++ b/gprofng/examples/mxv-pthreads/src/main.c
> @@ -370,5 +370,6 @@ int64_t check_results (int64_t m, int64_t n, double *c, double *ref)
> printf (" %c c[%ld] = %f ref[%ld] = %f\n",marker[i],i,c[i],i,ref[i]);
> }
>
> + free(marker);
> return (errors);
> }
I question the need for this (and in fact all the free()s in main(), though.
The program is about to exit anyway.
In any event, separating by component may be advisable, as in principle
different people (who you would have wanted to Cc) will want to approve the
two parts.
Jan
@@ -1884,6 +1884,8 @@ bfin_gen_loop (Expr_Node *exp, REG_T reg, int rop, REG_T preg)
if (!S_IS_LOCAL (sym) || (S_IS_LOCAL (sym) && !symbol_used_p (sym)))
symbol_remove (sym, &symbol_rootP, &symbol_lastP);
+ free(lbeginsym);
+ free(lendsym);
return bfin_gen_loopsetup (lbegin, reg, rop, lend, preg);
}
@@ -1919,6 +1921,8 @@ bfin_loop_beginend (Expr_Node *exp, int begin)
Adjust label address. */
if (!begin)
*symbol_X_add_number (linelabel) -= last_insn_size;
+
+ free(label_name);
}
bool
@@ -370,5 +370,6 @@ int64_t check_results (int64_t m, int64_t n, double *c, double *ref)
printf (" %c c[%ld] = %f ref[%ld] = %f\n",marker[i],i,c[i],i,ref[i]);
}
+ free(marker);
return (errors);
}