qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/8] target/xtensa: Replaced malloc/free with GLib's variants


From: Max Filippov
Subject: Re: [PATCH 4/8] target/xtensa: Replaced malloc/free with GLib's variants
Date: Sun, 14 Mar 2021 08:38:30 -0700

On Sat, Mar 13, 2021 at 7:23 PM Mahmoud Mandour <ma.mandourr@gmail.com> 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 <ma.mandourr@gmail.com>
> ---
>  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 <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]