cc: Use `unique_ptr` instead of `shared_ptr`
authorVicent Marti <tanoku@gmail.com>
Fri, 6 May 2016 08:51:54 +0000 (10:51 +0200)
committerVicent Marti <tanoku@gmail.com>
Fri, 6 May 2016 09:01:20 +0000 (11:01 +0200)
src/cc/usdt.cc
src/cc/usdt.h

index 2d7d8f6..c2b9459 100644 (file)
@@ -229,10 +229,10 @@ std::string Context::resolve_bin_path(const std::string &bin_path) {
   return result;
 }
 
-std::shared_ptr<Probe> Context::get(const std::string &probe_name) {
+Probe *Context::get(const std::string &probe_name) {
   for (auto &p : probes_) {
     if (p->name_ == probe_name)
-      return p;
+      return p.get();
   }
   return nullptr;
 }
index 412bb84..e67d89c 100644 (file)
@@ -166,7 +166,7 @@ public:
 };
 
 class Context {
-  std::vector<std::shared_ptr<Probe>> probes_;
+  std::vector<std::unique_ptr<Probe>> probes_;
 
   optional<int> pid_;
   optional<ProcStat> pid_stat_;
@@ -188,8 +188,8 @@ public:
   bool loaded() const { return loaded_; }
   size_t num_probes() const { return probes_.size(); }
 
-  std::shared_ptr<Probe> get(const std::string &probe_name);
-  std::shared_ptr<Probe> get(int pos) { return probes_[pos]; }
+  Probe *get(const std::string &probe_name);
+  Probe *get(int pos) { return probes_[pos].get(); }
 
   bool enable_probe(const std::string &probe_name, const std::string &fn_name);
   bool generate_usdt_args(std::ostream &stream);