Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sanitize the includes of context objects declarations (was dupplicated and a bit...
[simgrid.git] / src / simix / smx_context_lua.c
index 5c3c3e9..377cf13 100644 (file)
@@ -7,10 +7,7 @@
 /* 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. */
 
 /* 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 "context_sysv_config.h"        /* loads context system definitions */
-//#include "portable.h"
-//#include <ucontext.h>           /* context relative declarations */
+#include "smx_context_private.h"
 #include <lua5.1/lauxlib.h>
 #include <lua5.1/lualib.h>
 
 #include <lua5.1/lauxlib.h>
 #include <lua5.1/lualib.h>
 
@@ -64,7 +61,7 @@ void SIMIX_ctx_lua_factory_set_state(void* state) {
 }
 void SIMIX_ctx_lua_factory_init(smx_context_factory_t *factory) {
 
 }
 void SIMIX_ctx_lua_factory_init(smx_context_factory_t *factory) {
 
-  *factory = xbt_new0(s_smx_context_factory_t, 1);
+  smx_ctx_base_factory_init(factory);
 
   (*factory)->create_context = smx_ctx_lua_create_context;
   (*factory)->finalize = smx_ctx_lua_factory_finalize;
 
   (*factory)->create_context = smx_ctx_lua_create_context;
   (*factory)->finalize = smx_ctx_lua_factory_finalize;
@@ -80,9 +77,7 @@ void SIMIX_ctx_lua_factory_init(smx_context_factory_t *factory) {
 static int smx_ctx_lua_factory_finalize(smx_context_factory_t * factory) {
   lua_close(lua_state);
 
 static int smx_ctx_lua_factory_finalize(smx_context_factory_t * factory) {
   lua_close(lua_state);
 
-  free(*factory);
-  *factory = NULL;
-  return 0;
+  return smx_ctx_base_factory_finalize(factory);
 }
 
 static smx_context_t 
 }
 
 static smx_context_t 
@@ -126,29 +121,16 @@ smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char** argv,
   return (smx_context_t)context;
 }
 
   return (smx_context_t)context;
 }
 
-static void smx_ctx_lua_free(smx_context_t pcontext)
-{
-  int i;
-  smx_ctx_lua_t context = (smx_ctx_lua_t)pcontext;
+static void smx_ctx_lua_free(smx_context_t context) {
 
   if (context){
     DEBUG1("smx_ctx_lua_free_context(%p)",context);
 
 
   if (context){
     DEBUG1("smx_ctx_lua_free_context(%p)",context);
 
-    /* free argv */
-    if (context->super.argv) {
-      for (i = 0; i < context->super.argc; i++)
-        if (context->super.argv[i])
-          free(context->super.argv[i]);
-
-      free(context->super.argv);
-    }
-
     /* let the lua garbage collector reclaim the thread used for the coroutine */
     /* let the lua garbage collector reclaim the thread used for the coroutine */
-    luaL_unref(lua_state,LUA_REGISTRYINDEX,context->ref );
-
-    free(context);
-    context = NULL;
+    luaL_unref(lua_state,LUA_REGISTRYINDEX,((smx_ctx_lua_t)context)->ref );
   }
   }
+
+  smx_ctx_base_free(context);
 }
 
 static void smx_ctx_lua_stop(smx_context_t pcontext) {
 }
 
 static void smx_ctx_lua_stop(smx_context_t pcontext) {