This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C++ify osdata


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]