On Sat, Mar 13, 2021 at 7:23 PM Mahmoud Mandour <[email protected]> wrote:
>
> Replaced the calls to malloc() and their respective calls to
> free() with GLib's allocation and deallocation functions.
>
> Removed null checking before calling g_free() because it's
> not necessary and generates style errors.
>
> Signed-off-by: Mahmoud Mandour <[email protected]>
> ---
> target/xtensa/xtensa-isa.c | 53 +++++++++++++++-----------------------
> 1 file changed, 21 insertions(+), 32 deletions(-)
>
> diff --git a/target/xtensa/xtensa-isa.c b/target/xtensa/xtensa-isa.c
> index 630b4f9da1..5afdba77aa 100644
> --- a/target/xtensa/xtensa-isa.c
> +++ b/target/xtensa/xtensa-isa.c
[...]
> @@ -332,36 +332,25 @@ void xtensa_isa_free(xtensa_isa isa)
> * structure to its initial state.
> */
>
> - if (intisa->opname_lookup_table) {
> - free(intisa->opname_lookup_table);
> - intisa->opname_lookup_table = 0;
> - }
> + g_free(intisa->opname_lookup_table);
> + intisa->opname_lookup_table = 0;
This 0 should be replaced with NULL.
>
> - if (intisa->state_lookup_table) {
> - free(intisa->state_lookup_table);
> - intisa->state_lookup_table = 0;
> - }
> + g_free(intisa->state_lookup_table);
> + intisa->state_lookup_table = 0;
Ditto.
> +
> + g_free(intisa->sysreg_lookup_table);
> + intisa->sysreg_lookup_table = 0;
Ditto.
>
> - if (intisa->sysreg_lookup_table) {
> - free(intisa->sysreg_lookup_table);
> - intisa->sysreg_lookup_table = 0;
> - }
> for (n = 0; n < 2; n++) {
> - if (intisa->sysreg_table[n]) {
> - free(intisa->sysreg_table[n]);
> - intisa->sysreg_table[n] = 0;
> - }
> + g_free(intisa->sysreg_table[n]);
> + intisa->sysreg_table[n] = 0;
Ditto.
> }
>
> - if (intisa->interface_lookup_table) {
> - free(intisa->interface_lookup_table);
> - intisa->interface_lookup_table = 0;
> - }
> + g_free(intisa->interface_lookup_table);
> + intisa->interface_lookup_table = 0;
Ditto.
>
> - if (intisa->funcUnit_lookup_table) {
> - free(intisa->funcUnit_lookup_table);
> - intisa->funcUnit_lookup_table = 0;
> - }
> + g_free(intisa->funcUnit_lookup_table);
> + intisa->funcUnit_lookup_table = 0;
Ditto.
With the above changes:
Acked-by: Max Filippov <[email protected]>
--
Thanks.
-- Max