This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] C++ify osdata
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>, gdb-patches at sourceware dot org
- Date: Thu, 23 Nov 2017 12:54:24 +0000
- Subject: Re: [PATCH] C++ify osdata
- Authentication-results: sourceware.org; auth=none
- References: <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