Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[S4U] NULL -> nullptr substitution
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Wed, 8 Jun 2016 21:20:59 +0000 (23:20 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 9 Jun 2016 07:39:07 +0000 (09:39 +0200)
I used the following command: (the '**' means recursion in ZSH)
sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp

We check for the underscore to avoid replacing MPI_*_NULL

src/s4u/s4u_actor.cpp
src/s4u/s4u_as.cpp
src/s4u/s4u_comm.cpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_host.cpp
src/s4u/s4u_storage.cpp

index 37302a7..2170f74 100644 (file)
@@ -24,7 +24,7 @@ s4u::Actor::Actor(const char* name, s4u::Host *host, double killTime, std::funct
   // instance will get a fresh (reinitialized) state. Is this what we want?
   this->pimpl_ = simcall_process_create(
     name, std::move(code), nullptr, host->name().c_str(),
-    killTime, NULL, 0);
+    killTime, nullptr, 0);
 }
 
 s4u::Actor::~Actor() {}
@@ -59,7 +59,7 @@ double s4u::Actor::getKillTime() {
 
 void s4u::Actor::kill(int pid) {
   msg_process_t process = SIMIX_process_from_PID(pid);
-  if(process != NULL) {
+  if(process != nullptr) {
     simcall_process_kill(process);
   } else {
     std::ostringstream oss;
@@ -88,12 +88,12 @@ void sleep(double duration) {
 }
 
 e_smx_state_t execute(double flops) {
-  smx_synchro_t s = simcall_execution_start(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
+  smx_synchro_t s = simcall_execution_start(nullptr,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
   return simcall_execution_wait(s);
 }
 
 void* recv(Mailbox &chan) {
-  void *res = NULL;
+  void *res = nullptr;
   Comm c = Comm::recv_init(chan);
   c.setDstData(&res,sizeof(res));
   c.wait();
index b0f760f..70338f6 100644 (file)
@@ -25,7 +25,7 @@ namespace simgrid {
     }
     As::~As()
     {
-      xbt_dict_cursor_t cursor = NULL;
+      xbt_dict_cursor_t cursor = nullptr;
       char *key;
       AS_t elem;
       xbt_dict_foreach(children_, cursor, key, elem) {
@@ -54,12 +54,12 @@ namespace simgrid {
 
     xbt_dynar_t As::hosts()
     {
-      xbt_dynar_t res =  xbt_dynar_new(sizeof(sg_host_t), NULL);
+      xbt_dynar_t res =  xbt_dynar_new(sizeof(sg_host_t), nullptr);
 
       for (unsigned int index = 0; index < xbt_dynar_length(vertices_); index++) {
         simgrid::surf::NetCard *card = xbt_dynar_get_as(vertices_, index, simgrid::surf::NetCard*);
         simgrid::s4u::Host     *host = simgrid::s4u::Host::by_name_or_null(card->name());
-        if (host!=NULL)
+        if (host!=nullptr)
           xbt_dynar_push(res, &host);
       }
       return res;
index 93e1c50..d27cfb0 100644 (file)
@@ -37,7 +37,7 @@ void s4u::Comm::setRate(double rate) {
 
 void s4u::Comm::setSrcData(void * buff) {
   xbt_assert(state_==inited);
-  xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+  xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
   srcBuff_ = buff;
 }
 void s4u::Comm::setSrcDataSize(size_t size){
@@ -47,13 +47,13 @@ void s4u::Comm::setSrcDataSize(size_t size){
 void s4u::Comm::setSrcData(void * buff, size_t size) {
   xbt_assert(state_==inited);
 
-  xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+  xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
   srcBuff_ = buff;
   srcBuffSize_ = size;
 }
 void s4u::Comm::setDstData(void ** buff) {
   xbt_assert(state_==inited);
-  xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+  xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
   dstBuff_ = buff;
 }
 size_t s4u::Comm::getDstDataSize(){
@@ -63,7 +63,7 @@ size_t s4u::Comm::getDstDataSize(){
 void s4u::Comm::setDstData(void ** buff, size_t size) {
   xbt_assert(state_==inited);
 
-  xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+  xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
   dstBuff_ = buff;
   dstBuffSize_ = size;
 }
@@ -71,12 +71,12 @@ void s4u::Comm::setDstData(void ** buff, size_t size) {
 void s4u::Comm::start() {
   xbt_assert(state_ == inited);
 
-  if (srcBuff_ != NULL) { // Sender side
+  if (srcBuff_ != nullptr) { // Sender side
     pimpl_ = simcall_comm_isend(sender_, mailbox_->getInferior(), remains_, rate_,
         srcBuff_, srcBuffSize_,
         matchFunction_, cleanFunction_, copyDataFunction_,
         userData_, detached_);
-  } else if (dstBuff_ != NULL) { // Receiver side
+  } else if (dstBuff_ != nullptr) { // Receiver side
     pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getInferior(), dstBuff_, &dstBuffSize_,
         matchFunction_, copyDataFunction_,
         userData_, rate_);
@@ -92,7 +92,7 @@ void s4u::Comm::wait() {
   if (state_ == started)
     simcall_comm_wait(pimpl_, -1/*timeout*/);
   else {// p_state == inited. Save a simcall and do directly a blocking send/recv
-    if (srcBuff_ != NULL) {
+    if (srcBuff_ != nullptr) {
       simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
           srcBuff_, srcBuffSize_,
           matchFunction_, copyDataFunction_,
@@ -115,7 +115,7 @@ void s4u::Comm::wait(double timeout) {
   }
 
   // It's not started yet. Do it in one simcall
-  if (srcBuff_ != NULL) {
+  if (srcBuff_ != nullptr) {
     simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
         srcBuff_, srcBuffSize_,
         matchFunction_, copyDataFunction_,
index 1f6a490..73b3b7c 100644 (file)
@@ -82,12 +82,12 @@ static s4u::As *asByNameRecursive(s4u::As *current, const char *name)
   if(!strcmp(current->name(), name))
     return current;
 
-  xbt_dict_cursor_t cursor = NULL;
+  xbt_dict_cursor_t cursor = nullptr;
   char *key;
   AS_t elem;
   xbt_dict_foreach(current->children(), cursor, key, elem) {
     simgrid::s4u::As *tmp = asByNameRecursive(elem, name);
-    if (tmp != NULL )
+    if (tmp != nullptr )
         return tmp;
   }
   return nullptr;
index 8c70f80..7b9c90b 100644 (file)
@@ -63,14 +63,14 @@ Host* Host::by_name_or_create(const char* name)
   Host* host = by_name_or_null(name);
   if (host == nullptr) {
     host = new Host(name);
-    xbt_dict_set(host_list, name, host, NULL);
+    xbt_dict_set(host_list, name, host, nullptr);
   }
   return host;
 }
 
 Host *Host::current(){
   smx_process_t smx_proc = SIMIX_process_self();
-  if (smx_proc == NULL)
+  if (smx_proc == nullptr)
     xbt_die("Cannot call Host::current() from the maestro context");
   return SIMIX_process_get_host(smx_proc);
 }
@@ -92,7 +92,7 @@ int Host::pstatesCount() const {
 }
 
 boost::unordered_map<std::string, Storage*> const& Host::mountedStorages() {
-  if (mounts == NULL) {
+  if (mounts == nullptr) {
     mounts = new boost::unordered_map<std::string, Storage*> ();
 
     xbt_dict_t dict = this->mountedStoragesAsDict();
@@ -117,7 +117,7 @@ xbt_dict_t Host::properties() {
   });
 }
 
-/** Retrieve the property value (or NULL if not set) */
+/** Retrieve the property value (or nullptr if not set) */
 const char*Host::property(const char*key) {
   simgrid::surf::HostImpl* surf_host = this->extension<simgrid::surf::HostImpl>();
   return surf_host->getProperty(key);
index afc3401..04c1ee4 100644 (file)
@@ -28,12 +28,12 @@ smx_storage_t Storage::inferior() {
   return pimpl_;
 }
 Storage &Storage::byName(const char*name) {
-  s4u::Storage *res = NULL;
+  s4u::Storage *res = nullptr;
   try {
     res = storages_->at(name);
   } catch (std::out_of_range& e) {
     smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name);
-    if (inferior == NULL)
+    if (inferior == nullptr)
       xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name);
 
     res = new Storage(name,inferior);