QEMU-Devel Archive mirror
 help / color / mirror / Atom feed
From: Konstantin Kostiuk <konstantin@daynix.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: QEMU <qemu-devel@nongnu.org>, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [PATCH] qga-win: Free GMatchInfo properly
Date: Thu, 10 Jun 2021 17:53:35 +0300	[thread overview]
Message-ID: <CAJ28CFROd2KPknSoT=P6NS2PzizsTi=K4tKx0dV5By=cqKUDJg@mail.gmail.com> (raw)
In-Reply-To: <CAJ+F1C+WhQRd7W4ATJh=QeyRnYULipPFHr38MODwrLc6Gu73eQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]

Hi All,

For freeing GMatchInfo struct, a special function is required. I'm not sure is
it possible to use g_autoptr in this case or no.
In GLib example
https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-regex-match,
g_match_info_free is used directly.

Best wishes,
Kostiantyn Kostiuk


On Thu, Jun 10, 2021 at 5:41 PM Marc-André Lureau <
marcandre.lureau@gmail.com> wrote:

> Hi
>
> On Thu, Jun 10, 2021 at 6:38 PM Kostiantyn Kostiuk <konstantin@daynix.com>
> wrote:
>
>> The g_regex_match function creates match_info even if it
>> returns FALSE. So we should always call g_match_info_free.
>>
>> Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com>
>> ---
>>  qga/commands-win32.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
>> index 300b87c859..e8bc3df306 100644
>> --- a/qga/commands-win32.c
>> +++ b/qga/commands-win32.c
>> @@ -2497,6 +2497,7 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error
>> **errp)
>>              GMatchInfo *match_info;
>>
>
> What about using g_autoptr instead?
>
>              GuestDeviceIdPCI *id;
>>              if (!g_regex_match(device_pci_re, hw_ids[j], 0,
>> &match_info)) {
>> +                g_match_info_free(match_info);
>>                  continue;
>>              }
>>              skip = false;
>> --
>> 2.25.1
>>
>>
>>
>
> --
> Marc-André Lureau
>

[-- Attachment #2: Type: text/html, Size: 2741 bytes --]

  reply	other threads:[~2021-06-10 14:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 14:38 [PATCH] qga-win: Free GMatchInfo properly Kostiantyn Kostiuk
2021-06-10 14:41 ` Marc-André Lureau
2021-06-10 14:53   ` Konstantin Kostiuk [this message]
2021-06-10 15:23     ` Daniel P. Berrangé
2021-06-10 15:59       ` Konstantin Kostiuk

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='CAJ28CFROd2KPknSoT=P6NS2PzizsTi=K4tKx0dV5By=cqKUDJg@mail.gmail.com' \
    --to=konstantin@daynix.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@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 read-only IMAP folder(s) and NNTP newsgroup(s).