Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / xbt / memory_map.cpp
index 248d12d..c81bcfb 100644 (file)
@@ -1,8 +1,9 @@
-/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2021. 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. */
 
+#include <array>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
@@ -74,7 +75,7 @@ std::vector<VmMap> get_memory_map(pid_t pid)
 
   /*
    * Darwin do not give us the number of mappings, so we read entries until
-   * we get an KERN_INVALID_ADDRESS return.
+   * we get a KERN_INVALID_ADDRESS return.
    */
   mach_vm_address_t address = VM_MIN_ADDRESS;
   while (true) {
@@ -162,7 +163,7 @@ std::vector<VmMap> get_memory_map(pid_t pid)
   /* to be returned. */
   std::string path = std::string("/proc/") + std::to_string(pid) + "/maps";
   std::ifstream fp;
-  fp.rdbuf()->pubsetbuf(0, 0);
+  fp.rdbuf()->pubsetbuf(nullptr, 0);
   fp.open(path);
   if (not fp) {
     std::perror("open failed");
@@ -181,7 +182,7 @@ std::vector<VmMap> get_memory_map(pid_t pid)
 
     /* Tokenize the line using spaces as delimiters and store each token in lfields array. We expect 5 tokens for 6 fields */
     char* saveptr = nullptr; // for strtok_r()
-    char* lfields[6];
+    std::array<char*, 6> lfields;
     lfields[0] = strtok_r(line, " ", &saveptr);
 
     int i;