From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] C++ify osdata
Date: Thu, 23 Nov 2017 12:54:00 -0000 [thread overview]
Message-ID: <9d0b9473-1fd5-8310-0cde-8233efed58bc@redhat.com> (raw)
In-Reply-To: <20171118233827.7418-1-simon.marchi@polymtl.ca>
Hi Simon,
I think I spotted an issue here.
On 11/18/2017 11:38 PM, Simon Marchi wrote:
> + /* This keeps a map from integer (pid) to vector of struct osdata_item.
> + The vector contains information about all threads for the given pid. */
> + std::map<int, std::vector<osdata_item> *> tree_;
Isn't this leaking the heap-allocated vectors?
Why make it a map of pointers, actually? Why not:
std::map<int, std::vector<osdata_item>>
It's more efficient, and I think results in simpler code. You
won't need the tree_.find() for example, can just do:
tree_[pid_i].push_back (...);
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-11-23 12:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 23:38 Simon Marchi
2017-11-22 21:15 ` Simon Marchi
2017-11-23 12:54 ` Pedro Alves [this message]
2017-11-23 18:39 ` Simon Marchi
2017-11-23 22:46 ` Pedro Alves
2017-11-24 2:58 ` 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=9d0b9473-1fd5-8310-0cde-8233efed58bc@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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