Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't memset to zero
[simgrid.git] / src / bindings / lua / lua_utils.c
index 55721bc..3f1f523 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_utils, lua, "Lua helper functions");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_utils, bindings, "Lua helper functions");
 
 /**
  * @brief Returns a string representation of a value in the Lua stack.
@@ -103,7 +103,9 @@ const char* sglua_get_spaces(int length) {
   static char spaces[128];
 
   xbt_assert(length < 128);
-  memset(spaces, ' ', length);
+  if (length != 0) {
+    memset(spaces, ' ', length);
+  }
   spaces[length] = '\0';
   return spaces;
 }
@@ -140,7 +142,6 @@ void sglua_stack_dump(const char* msg, lua_State* L)
  *
  * This function is a valid lua_Writer that writes into a memory buffer passed
  * as userdata.
- * TODO: use a dynar as userdata
  *
  * @param L a lua state
  * @param source some data
@@ -150,7 +151,7 @@ void sglua_stack_dump(const char* msg, lua_State* L)
 int sglua_memory_writer(lua_State* L, const void* source, size_t size,
     void* userdata) {
 
-  buffer_t buffer = (buffer_t) userdata;
+  sglua_buffer_t buffer = (sglua_buffer_t) userdata;
   while (buffer->capacity < buffer->size + size) {
     buffer->capacity *= 2;
     buffer->data = xbt_realloc(buffer->data, buffer->capacity);