Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Flavio Cruz <flaviocruz@gmail.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,  Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] Hurd: remove VLA usage.
Date: Wed, 18 Dec 2024 08:14:32 -0700	[thread overview]
Message-ID: <87zfktauqv.fsf@tromey.com> (raw)
In-Reply-To: <t434vaztj3daruoeik5p63xhfpoobrf2nmxvbcldx6n6fgooqh@t7muqodl2hbv> (Flavio Cruz's message of "Wed, 18 Dec 2024 01:27:19 -0500")

>>>>> "Flavio" == Flavio Cruz <flaviocruz@gmail.com> writes:

Flavio> Compilation will fail with -Werror=vla, which seems to be the default.
Flavio> Note that we can allocate just an array of num_threads pointers,
Flavio> hence the change.

Flavio> -    /* Which thread in PROCS corresponds to each task thread, & the task.  */
Flavio> -    struct proc *matched[num_threads + 1];
Flavio> +    /* Which thread in PROCS corresponds to each task thread.  */
Flavio> +    struct proc **matched = XNEWVEC (struct proc *, num_threads);

Since this is in C++ code I think you could use

    std::vector<proc *> matched (num_threads + 1, nullptr);

Flavio> +    xfree (matched);

... that would avoid the explicit free.

Tom

      reply	other threads:[~2024-12-18 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18  6:27 Flavio Cruz
2024-12-18 15:14 ` Tom Tromey [this message]

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=87zfktauqv.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=flaviocruz@gmail.com \
    --cc=gdb-patches@sourceware.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