Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a bunch of memleaks
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Feb 2017 03:19:20 +0000 (04:19 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Feb 2017 03:19:20 +0000 (04:19 +0100)
src/bindings/lua/lua_platf.cpp
src/surf/xml/surfxml_parseplatf.cpp

index 37a22c0..41f408c 100644 (file)
@@ -311,9 +311,6 @@ int console_add_route(lua_State *L) {
   memset(&route,0,sizeof(route));
   int type;
 
   memset(&route,0,sizeof(route));
   int type;
 
-  /* allocating memory for the buffer, I think 2kB should be enough */
-  surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size);
-
   lua_ensure(lua_istable(L, -1), "Bad Arguments to add a route. Should be a table with named arguments");
 
   lua_pushstring(L,"src");
   lua_ensure(lua_istable(L, -1), "Bad Arguments to add a route. Should be a table with named arguments");
 
   lua_pushstring(L,"src");
@@ -352,6 +349,7 @@ int console_add_route(lua_State *L) {
       }
     }
   }
       }
     }
   }
+  xbt_dynar_free(&names);
   lua_pop(L,1);
 
   /* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
   lua_pop(L,1);
 
   /* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
@@ -378,6 +376,7 @@ int console_add_route(lua_State *L) {
   route.gw_dst = nullptr;
 
   sg_platf_new_route(&route);
   route.gw_dst = nullptr;
 
   sg_platf_new_route(&route);
+  delete route.link_list;
 
   return 0;
 }
 
   return 0;
 }
@@ -449,6 +448,7 @@ int console_add_ASroute(lua_State *L) {
   lua_pop(L,1);
 
   sg_platf_new_route(&ASroute);
   lua_pop(L,1);
 
   sg_platf_new_route(&ASroute);
+  delete ASroute.link_list;
 
   return 0;
 }
 
   return 0;
 }
index 9527602..14ebf6d 100644 (file)
@@ -147,9 +147,10 @@ void parse_platform_file(const char *file)
 
     /* Run the script */
     if (lua_pcall(L, 0, 0, 0)) {
 
     /* 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
   }
   else
 #endif