Refactoring: don't pass list via pointer.
authorDavin McCall <davmac@davmac.org>
Fri, 16 Jun 2017 17:31:24 +0000 (18:31 +0100)
committerDavin McCall <davmac@davmac.org>
Fri, 16 Jun 2017 17:31:24 +0000 (18:31 +0100)
src/load_service.cc
src/service.cc
src/service.h

index 496341da878eee19c5799b2e6c175c09f5ab107b..8ebab76092d3d7455b4902c0fcde39de64e465a5 100644 (file)
@@ -585,14 +585,14 @@ service_record * dirload_service_set::load_service(const char * name)
                 delete rval;
                 if (service_type == service_type::PROCESS) {
                     auto rvalps = new process_service(this, string(name), std::move(command),
-                        command_offsets, &depends_on, &depends_soft);
+                            command_offsets, std::move(depends_on), depends_soft);
                     rvalps->set_restart_interval(restart_interval, max_restarts);
                     rvalps->set_restart_delay(restart_delay);
                     rval = rvalps;
                 }
                 else if (service_type == service_type::BGPROCESS) {
                     auto rvalps = new bgproc_service(this, string(name), std::move(command),
-                        command_offsets, &depends_on, &depends_soft);
+                            command_offsets, std::move(depends_on), depends_soft);
                     rvalps->set_pid_file(std::move(pid_file));
                     rvalps->set_restart_interval(restart_interval, max_restarts);
                     rvalps->set_restart_delay(restart_delay);
@@ -600,12 +600,13 @@ service_record * dirload_service_set::load_service(const char * name)
                 }
                 else if (service_type == service_type::SCRIPTED) {
                     rval = new scripted_service(this, string(name), std::move(command),
-                                                command_offsets, &depends_on, &depends_soft);
+                            command_offsets, std::move(depends_on), depends_soft);
                     rval->setStopCommand(stop_command, stop_command_offsets);
                 }
                 else {
-                    rval = new service_record(this, string(name), service_type, std::move(command), command_offsets,
-                            &depends_on, &depends_soft);
+                    rval = new service_record(this, string(name), service_type,
+                            std::move(command), command_offsets,
+                            std::move(depends_on), depends_soft);
                 }
                 rval->setLogfile(logfile);
                 rval->setAutoRestart(auto_restart);
index 21e8af43508a8a9900151978f3c01dfc2d9e0787..90d5b2e12cd459943bf5441b313c34343d08d722 100644 (file)
@@ -1212,9 +1212,9 @@ void service_set::service_inactive(service_record *sr) noexcept
 
 base_process_service::base_process_service(service_set *sset, string name, service_type service_type_p, string &&command,
         std::list<std::pair<unsigned,unsigned>> &command_offsets,
-        sr_list * pdepends_on, sr_list * pdepends_soft)
+        sr_list &&pdepends_on, const sr_list &pdepends_soft)
      : service_record(sset, name, service_type_p, std::move(command), command_offsets,
-         pdepends_on, pdepends_soft), child_listener(this), child_status_listener(this)
+         std::move(pdepends_on), pdepends_soft), child_listener(this), child_status_listener(this)
 {
     restart_interval_count = 0;
     restart_interval_time = {0, 0};
index 1828d52081b303907f03b55afcc1530602e000fd..0ee545dc584b460bd18f23679c0f0006b4057840 100644 (file)
@@ -430,13 +430,13 @@ class service_record
     }
 
     service_record(service_set *set, string name, service_type record_type_p,
-            sr_list * pdepends_on, sr_list * pdepends_soft)
+            sr_list &&pdepends_on, const sr_list &pdepends_soft)
         : service_record(set, name)
     {
         services = set;
         service_name = name;
         this->record_type = record_type_p;
-        this->depends_on = std::move(*pdepends_on);
+        this->depends_on = std::move(pdepends_on);
 
         for (sr_iter i = depends_on.begin(); i != depends_on.end(); ++i) {
             (*i)->dependents.push_back(this);
@@ -444,7 +444,7 @@ class service_record
 
         // Soft dependencies
         auto b_iter = soft_deps.end();
-        for (sr_iter i = pdepends_soft->begin(); i != pdepends_soft->end(); ++i) {
+        for (auto i = pdepends_soft.begin(); i != pdepends_soft.end(); ++i) {
             b_iter = soft_deps.emplace(b_iter, this, *i);
             (*i)->soft_dpts.push_back(&(*b_iter));
             ++b_iter;
@@ -452,8 +452,8 @@ class service_record
     }
     
     service_record(service_set *set, string name, service_type record_type_p, string &&command, std::list<std::pair<unsigned,unsigned>> &command_offsets,
-            sr_list * pdepends_on, sr_list * pdepends_soft)
-        : service_record(set, name, record_type_p, pdepends_on, pdepends_soft)
+            sr_list &&pdepends_on, const sr_list &pdepends_soft)
+        : service_record(set, name, record_type_p, std::move(pdepends_on), pdepends_soft)
     {
         program_name = std::move(command);
         exec_arg_parts = separate_args(program_name, command_offsets);
@@ -645,7 +645,7 @@ class base_process_service : public service_record
     public:
     base_process_service(service_set *sset, string name, service_type record_type_p, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
-            sr_list * pdepends_on, sr_list * pdepends_soft);
+            sr_list &&pdepends_on, const sr_list &pdepends_soft);
 
     ~base_process_service() noexcept
     {
@@ -672,9 +672,9 @@ class process_service : public base_process_service
     public:
     process_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
-            sr_list * pdepends_on, sr_list * pdepends_soft)
+            sr_list &&pdepends_on, const sr_list &pdepends_soft)
          : base_process_service(sset, name, service_type::PROCESS, std::move(command), command_offsets,
-             pdepends_on, pdepends_soft)
+             std::move(pdepends_on), pdepends_soft)
     {
     }
 
@@ -696,9 +696,9 @@ class bgproc_service : public base_process_service
     public:
     bgproc_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
-            sr_list * pdepends_on, sr_list * pdepends_soft)
+            sr_list &&pdepends_on, const sr_list &pdepends_soft)
          : base_process_service(sset, name, service_type::BGPROCESS, std::move(command), command_offsets,
-             pdepends_on, pdepends_soft)
+             std::move(pdepends_on), pdepends_soft)
     {
         doing_recovery = false;
     }
@@ -716,9 +716,9 @@ class scripted_service : public base_process_service
     public:
     scripted_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
-            sr_list * pdepends_on, sr_list * pdepends_soft)
+            sr_list &&pdepends_on, const sr_list &pdepends_soft)
          : base_process_service(sset, name, service_type::SCRIPTED, std::move(command), command_offsets,
-             pdepends_on, pdepends_soft)
+             std::move(pdepends_on), pdepends_soft)
     {
     }