qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-trivial@nongnu.org
Subject: Re: [PATCH for-8.2 2/2] target/ppc: use g_free() in test_opcode_table()
Date: Sun, 30 Jul 2023 14:05:54 -0300	[thread overview]
Message-ID: <93fcb62b-7e16-fc9b-3741-53fbbb44cc5f@gmail.com> (raw)
In-Reply-To: <CAFEAcA9vsv4BpSfFb6=W=MFjGdR283KEGFN13Sfy=TxtcjT4hA@mail.gmail.com>



On 7/29/23 12:32, Peter Maydell wrote:
> On Fri, 28 Jul 2023 at 21:47, Daniel Henrique Barboza
> <danielhb413@gmail.com> wrote:
>>
>> Use g_free(table[i]) instead of free(table[i]) to comply with QEMU low
>> level memory management guidelines.
>>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>> ---
>>   target/ppc/translate.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
>> index e6a0709066..d90535266e 100644
>> --- a/target/ppc/translate.c
>> +++ b/target/ppc/translate.c
>> @@ -7129,7 +7129,7 @@ static int test_opcode_table(opc_handler_t **table, int len)
>>                   tmp = test_opcode_table(ind_table(table[i]),
>>                       PPC_CPU_INDIRECT_OPCODES_LEN);
>>                   if (tmp == 0) {
>> -                    free(table[i]);
>> +                    g_free(table[i]);
>>                       table[i] = &invalid_handler;
>>                   } else {
>>                       count++;
> 
> Where is the allocation that this memory is free()ing? I
> think it is the g_new() in create_new_table(), but the code
> is a little complicated for me to understand...

It's on create_new_table() in the same file:

static int create_new_table(opc_handler_t **table, unsigned char idx)
{
     opc_handler_t **tmp;

     tmp = g_new(opc_handler_t *, PPC_CPU_INDIRECT_OPCODES_LEN);
     fill_new_table(tmp, PPC_CPU_INDIRECT_OPCODES_LEN);
     table[idx] = (opc_handler_t *)((uintptr_t)tmp | PPC_INDIRECT);

     return 0;
}


I probably should've mentioned in the commit msg ...


Daniel


> 
> thanks
> -- PMM


  reply	other threads:[~2023-07-30 17:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28 19:56 [PATCH for-8.2 0/2] ppc: get rid of free() (gitlab #1798) Daniel Henrique Barboza
2023-07-28 19:56 ` [PATCH for-8.2 1/2] hw/ppc: use g_free() in spapr_tce_table_post_load() Daniel Henrique Barboza
2023-07-29 15:26   ` Peter Maydell
2023-07-28 19:56 ` [PATCH for-8.2 2/2] target/ppc: use g_free() in test_opcode_table() Daniel Henrique Barboza
2023-07-29 15:32   ` Peter Maydell
2023-07-30 17:05     ` Daniel Henrique Barboza [this message]
2023-07-29 15:35 ` [PATCH for-8.2 0/2] ppc: get rid of free() (gitlab #1798) Peter Maydell
2023-07-30 17:13   ` Daniel Henrique Barboza
2023-09-07 19:27     ` Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93fcb62b-7e16-fc9b-3741-53fbbb44cc5f@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).