X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/187fd0eeffe07e62ceef374ae965f04f81138e7c..8b9696f20b03e9968251c7d4eb34061ef0ede759:/src/smpi/smpi_c99.c diff --git a/src/smpi/smpi_c99.c b/src/smpi/smpi_c99.c index 32e0265104..567f26a7d2 100644 --- a/src/smpi/smpi_c99.c +++ b/src/smpi/smpi_c99.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011. The SimGrid Team. +/* Copyright (c) 2011-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,20 +7,27 @@ #include #include "private.h" +typedef struct s_smpi_static { + void *ptr; + void_f_pvoid_t free_fn; +} s_smpi_static_t; + static xbt_dynar_t registered_static_stack = NULL; -void smpi_register_static(void* arg) +void smpi_register_static(void* arg, void_f_pvoid_t free_fn) { + s_smpi_static_t elm = { arg, free_fn }; if (!registered_static_stack) - registered_static_stack = xbt_dynar_new(sizeof(void*), NULL); - xbt_dynar_push_as(registered_static_stack, void*, arg); + registered_static_stack = xbt_dynar_new(sizeof(s_smpi_static_t), NULL); + xbt_dynar_push_as(registered_static_stack, s_smpi_static_t, elm); } void smpi_free_static(void) { while (!xbt_dynar_is_empty(registered_static_stack)) { - void *p = xbt_dynar_pop_as(registered_static_stack, void*); - free(p); + s_smpi_static_t elm = + xbt_dynar_pop_as(registered_static_stack, s_smpi_static_t); + elm.free_fn(elm.ptr); } xbt_dynar_free(®istered_static_stack); }