Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use C++ string_view.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 23 Nov 2022 14:48:27 +0000 (15:48 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 23 Nov 2022 16:25:36 +0000 (17:25 +0100)
src/sthread/sthread_impl.cpp

index 433f26a..30e9a2a 100644 (file)
@@ -20,6 +20,7 @@
 #include <sstream>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string_view>
 #include <thread>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sthread, "pthread intercepter");
@@ -31,7 +32,7 @@ int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**
 {
   /* Do not intercept the main when run from SMPI: it will initialize the simulation properly */
   for (int i = 0; envp[i] != nullptr; i++)
-    if (strncmp(envp[i], "SMPI_GLOBAL_SIZE", strlen("SMPI_GLOBAL_SIZE")) == 0)
+    if (std::string_view(envp[i]).rfind("SMPI_GLOBAL_SIZE", 0) == 0)
       return raw_main(argc, argv, envp);
 
   /* If not in SMPI, the old main becomes an actor in a newly created simulation */