Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / xbt / xbt_str.cpp
index b38ad7d..dfd3d6b 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_str.cpp - various helping functions to deal with strings             */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,6 +9,7 @@
 #include "xbt/misc.h"
 #include "xbt/str.h" /* headers of these functions */
 #include "xbt/string.hpp"
+#include <array>
 
 /** @brief Splits a string into a dynar of strings
  *
@@ -28,18 +29,18 @@ xbt_dynar_t xbt_str_split(const char *s, const char *sep)
 {
   xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   const char *sep_dflt = " \t\n\r\x0B";
-  char is_sep[256] = { 1, 0 };
+  std::array<bool, 256> is_sep;
 
   /* check what are the separators */
-  memset(is_sep, 0, sizeof(is_sep));
+  is_sep.fill(false);
   if (not sep) {
     while (*sep_dflt)
-      is_sep[(unsigned char) *sep_dflt++] = 1;
+      is_sep[(unsigned char)*sep_dflt++] = true;
   } else {
     while (*sep)
-      is_sep[(unsigned char) *sep++] = 1;
+      is_sep[(unsigned char)*sep++] = true;
   }
-  is_sep[0] = 1; /* End of string is also separator */
+  is_sep[0] = true; /* End of string is also separator */
 
   /* Do the job */
   const char* p = s;