X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/767564a7460d44003b44c77fabccb4de82ab3e7e..eed33b5980ef79e3f979b80564fbd5314c47902d:/include/smpi/smpi_cocci.h diff --git a/include/smpi/smpi_cocci.h b/include/smpi/smpi_cocci.h index bcd150d3c8..f0823557b8 100644 --- a/include/smpi/smpi_cocci.h +++ b/include/smpi/smpi_cocci.h @@ -43,14 +43,20 @@ void __attribute__((weak,destructor)) __postfini_##name(void) { \ #define SMPI_VARGET_GLOBAL(name) name[smpi_process_index()] /* The following handle local static variables */ +/** @brief Make sure that the passed pointer is freed on process exit. + * + * This function is rather internal, mainly used for the + * privatization of global variables through coccinelle. + */ +XBT_PUBLIC(void) smpi_register_static(void* arg, void_f_pvoid_t free_fn); -XBT_PUBLIC(void) smpi_register_static(void* arg); +XBT_PUBLIC(void) smpi_free_static(void); #define SMPI_VARINIT_STATIC(name,type) \ static type *name = NULL; \ if(!name) { \ name = (type*)malloc(smpi_global_size() * sizeof(type)); \ - smpi_register_static(name); \ + smpi_register_static(name, xbt_free); \ } #define SMPI_VARINIT_STATIC_AND_SET(name,type,expr) \ @@ -63,7 +69,7 @@ if(!name) { \ for(i = 0; i < size; i++) { \ name[i] = value; \ } \ - smpi_register_static(name); \ + smpi_register_static(name, xbt_free); \ } #define SMPI_VARGET_STATIC(name) name[smpi_process_index()]