X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/995f4b8d55d3c6f2047962c524fdfab415d7a1ac..b1a2e45431d13cdf45ec8b1c91bf7d6ca8377c9d:/src/simix/smx_context_lua.c diff --git a/src/simix/smx_context_lua.c b/src/simix/smx_context_lua.c index 5c3c3e95db..377cf1383a 100644 --- a/src/simix/smx_context_lua.c +++ b/src/simix/smx_context_lua.c @@ -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. */ -#include "private.h" -//#include "context_sysv_config.h" /* loads context system definitions */ -//#include "portable.h" -//#include /* context relative declarations */ +#include "smx_context_private.h" #include #include @@ -64,7 +61,7 @@ void SIMIX_ctx_lua_factory_set_state(void* state) { } 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; @@ -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); - free(*factory); - *factory = NULL; - return 0; + return smx_ctx_base_factory_finalize(factory); } 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; } -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); - /* 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 */ - 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) {