Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please codacy
[simgrid.git] / src / smpi / smpi_f2c.cpp
index e1c05af..df584b4 100644 (file)
@@ -1,12 +1,13 @@
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. 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 "private.h"
-#include <vector>
+#include "src/smpi/private.h"
+#include "src/smpi/smpi_f2c.hpp"
+#include "src/smpi/smpi_process.hpp"
 
+#include <cstdio>
 
 namespace simgrid{
 namespace smpi{
@@ -31,12 +32,12 @@ int F2C::f2c_id(){
 };
 
 char* F2C::get_key(char* key, int id) {
-  snprintf(key, KEY_SIZE, "%x",id);
+  std::snprintf(key, KEY_SIZE, "%x",id);
   return key;
 }
 
 char* F2C::get_key_id(char* key, int id) {
-  snprintf(key, KEY_SIZE, "%x_%d",id, smpi_process_index());
+  std::snprintf(key, KEY_SIZE, "%x_%d",id, smpi_process()->index());
   return key;
 }
 
@@ -79,8 +80,8 @@ F2C* F2C::f2c(int id){
   if(f2c_lookup_==nullptr){
     f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
   }
-  char key[KEY_SIZE];
   if(id >= 0){
+    char key[KEY_SIZE];
     return static_cast<F2C*>(xbt_dict_get_or_null(f2c_lookup_, get_key(key, id)));
   }else
     return NULL;