X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/368be7990cfe509e3c7715d9ad28f5ca1b3d62ef..c94898122fc054483e0e4b0313cd52f385582d2a:/src/surf/model.c diff --git a/src/surf/model.c b/src/surf/model.c index 94b30f5b48..02104c2aaf 100644 --- a/src/surf/model.c +++ b/src/surf/model.c @@ -7,47 +7,55 @@ #include "surf_private.h" #include "xbt/dict.h" -static void void_die_impossible_paction(surf_action_t action) { - DIE_IMPOSSIBLE; +static void void_die_impossible_paction(surf_action_t action) +{ + DIE_IMPOSSIBLE; } -static int int_die_impossible_paction(surf_action_t action) { - DIE_IMPOSSIBLE; + +static int int_die_impossible_paction(surf_action_t action) +{ + DIE_IMPOSSIBLE; } /** @brief initialize common datastructures to all models */ -void surf_model_init(surf_model_t model) { - s_surf_action_t action; - - - model->common_private = xbt_new0(s_surf_model_private_t, 1); - - model->common_public.states.ready_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - model->common_public.states.running_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - model->common_public.states.failed_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - model->common_public.states.done_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - model->common_public.resource_set = xbt_dict_new(); - - model->common_public.action_free = int_die_impossible_paction; - model->common_public.action_cancel = void_die_impossible_paction; - model->common_public.action_recycle = void_die_impossible_paction; - +surf_model_t surf_model_init(void) +{ + s_surf_action_t action; + surf_model_t model = xbt_new0(s_surf_model_t, 1); + + model->model_private = xbt_new0(s_surf_model_private_t, 1); + + model->states.ready_action_set = + xbt_swag_new(xbt_swag_offset(action, state_hookup)); + model->states.running_action_set = + xbt_swag_new(xbt_swag_offset(action, state_hookup)); + model->states.failed_action_set = + xbt_swag_new(xbt_swag_offset(action, state_hookup)); + model->states.done_action_set = + xbt_swag_new(xbt_swag_offset(action, state_hookup)); + model->resource_set = xbt_dict_new(); + + model->action_free = int_die_impossible_paction; + model->action_cancel = void_die_impossible_paction; + model->action_recycle = void_die_impossible_paction; + + return model; +} +/** @brief finalize common datastructures to all models */ +void surf_model_exit(surf_model_t model) +{ + xbt_swag_free(model->states.ready_action_set); + xbt_swag_free(model->states.running_action_set); + xbt_swag_free(model->states.failed_action_set); + xbt_swag_free(model->states.done_action_set); + xbt_dict_free(&model->resource_set); + free(model->model_private); + free(model); } -void* surf_model_resource_by_name(void* model, const char *name) { - return xbt_dict_get_or_null(((surf_model_t)model)->common_public.resource_set,name); +void *surf_model_resource_by_name(surf_model_t model, const char *name) +{ + return xbt_dict_get_or_null(model->resource_set, name); } -/** @brief finalize common datastructures to all models */ -void surf_model_exit(surf_model_t model) { - xbt_swag_free(model->common_public.states.ready_action_set); - xbt_swag_free(model->common_public.states.running_action_set); - xbt_swag_free(model->common_public.states.failed_action_set); - xbt_swag_free(model->common_public.states.done_action_set); - xbt_dict_free(&model->common_public.resource_set); - free(model->common_private); -}