Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a bunch of memleaks
[simgrid.git] / src / surf / xml / surfxml_parseplatf.cpp
index 95a8a10..14ebf6d 100644 (file)
@@ -12,7 +12,7 @@
 #include "src/surf/network_interface.hpp"
 #include "src/instr/instr_private.h" // TRACE_start(). FIXME: remove by subscribing tracing to the surf signals
 
-#include "src/surf/xml/platf.hpp"
+#include "src/surf/xml/platf_private.hpp"
 
 #if HAVE_LUA
 extern "C" {
@@ -119,7 +119,6 @@ void parse_after_config() {
 
     /* Register classical callbacks */
     storage_register_callbacks();
-    routing_register_callbacks();
 
     after_config_done = 1;
   }
@@ -129,8 +128,8 @@ void parse_after_config() {
 void parse_platform_file(const char *file)
 {
 #if HAVE_LUA
-  int is_lua = (file != nullptr && strlen(file) > 3 && file[strlen(file)-3] == 'l' && file[strlen(file)-2] == 'u'
-        && file[strlen(file)-1] == 'a');
+  int len    = (file == nullptr ? 0 : strlen(file));
+  int is_lua = (file != nullptr && len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a');
 #endif
 
   sg_platf_init();
@@ -148,9 +147,10 @@ void parse_platform_file(const char *file)
 
     /* Run the script */
     if (lua_pcall(L, 0, 0, 0)) {
-        XBT_ERROR("FATAL ERROR:\n  %s: %s\n\n", "Lua call failed. Errormessage:", lua_tostring(L, -1));
-        xbt_die("Lua call failed. See Log");
+      XBT_ERROR("FATAL ERROR:\n  %s: %s\n\n", "Lua call failed. Error message:", lua_tostring(L, -1));
+      xbt_die("Lua call failed. See Log");
     }
+    lua_close(L);
   }
   else
 #endif