public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: Tom Tromey <tom@tromey.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/3] gdb: use std::vector to store segments in symfile_segment_data
Date: Tue, 19 May 2020 10:52:19 -0400	[thread overview]
Message-ID: <8587474d-3714-d6b5-d1cc-85899b7e278c@efficios.com> (raw)
In-Reply-To: <87zha47z42.fsf@tromey.com>

On 2020-05-19 10:55 a.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon>    symfile_segment_data_up data (new symfile_segment_data);
> Simon> -  data->num_segments = num_segments;
> Simon> -  data->segment_bases = XCNEWVEC (CORE_ADDR, num_segments);
> Simon> -  data->segment_sizes = XCNEWVEC (CORE_ADDR, num_segments);
> 
> Simon>    for (i = 0; i < num_segments; i++)
> Simon> -    {
> Simon> -      data->segment_bases[i] = segments[i]->p_vaddr;
> Simon> -      data->segment_sizes[i] = segments[i]->p_memsz;
> Simon> -    }
> Simon> +    data->segments.emplace_back (segments[i]->p_vaddr, segments[i]->p_memsz);
> 
> It's probably better to just resize() to the desired size, instead of
> using emplace_back.  That may save some memory, because it won't
> over-allocate.
> 
> Probably not super important, but at the same time easy to do.

Good point, will do.  I probably can't resize if the elements are not
default constructible, but if I call reserve, it should work as well?

Simon

  reply	other threads:[~2020-05-19 14:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  1:35 [PATCH 0/3] C++ification of symfile_segment_data Simon Marchi
2020-05-19  1:35 ` [PATCH 1/3] gdb: allocate symfile_segment_data with new Simon Marchi
2020-05-19  1:35 ` [PATCH 2/3] gdb: use std::vector to store segments in symfile_segment_data Simon Marchi
2020-05-19 14:55   ` Tom Tromey
2020-05-19 14:52     ` Simon Marchi [this message]
2020-05-19 15:44       ` Tom Tromey
2020-05-19  1:35 ` [PATCH 3/3] gdb: make symfile_segment_data::segment_info an std::vector Simon Marchi
2020-05-19 14:57 ` [PATCH 0/3] C++ification of symfile_segment_data Tom Tromey
2020-05-19 16:25   ` Simon Marchi

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=8587474d-3714-d6b5-d1cc-85899b7e278c@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).