From: suter Date: Wed, 9 Oct 2013 07:49:07 +0000 (+0200) Subject: manage more cleanly the SIMIX_STORAGE_LEVEL X-Git-Tag: v3_9_90~34 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fa6da87c649e2f58a7daa031b1d12aa3768d3630 manage more cleanly the SIMIX_STORAGE_LEVEL --- diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index d91c628130..981891b839 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -109,6 +109,7 @@ void SIMIX_global_init(int *argc, char **argv) } SIMIX_HOST_LEVEL = xbt_lib_add_level(host_lib,SIMIX_host_destroy); + SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy); if (sg_cfg_get_boolean("clean_atexit")) atexit(SIMIX_clean); diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index d8477ae96b..07a354ca90 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -33,6 +33,22 @@ smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data) return xbt_lib_get_or_null(storage_lib, name, SIMIX_STORAGE_LEVEL); } +/** + * \brief Internal function to destroy a SIMIX storage. + * + * \param s the host to destroy (a smx_storage_t) + */ +void SIMIX_storage_destroy(void *s) +{ + smx_storage_priv_t storage = (smx_storage_priv_t) s; + + xbt_assert((storage != NULL), "Invalid parameters"); + if (storage->data) + free(storage->data); + + /* Clean storage structure */ + free(storage); +} void* SIMIX_pre_file_get_data(smx_simcall_t simcall,smx_file_t fd){ return SIMIX_file_get_data(fd); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 3cc035679b..a3fea00b10 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -21,6 +21,7 @@ static inline smx_storage_priv_t SIMIX_storage_priv(smx_storage_t storage){ } smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data); +void SIMIX_storage_destroy(void *s); void* SIMIX_pre_file_get_data(smx_simcall_t simcall,smx_file_t fd); void SIMIX_pre_file_set_data(smx_simcall_t simcall, smx_file_t fd, void *data); void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_storage_size_t size);