1 /* Copyright (c) 2011-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
9 typedef struct s_smpi_static {
11 void_f_pvoid_t free_fn;
15 * \brief Holds a reference to all static variables that were registered
16 * via smpi_register_static(). This helps to free them when
19 static std::stack<s_smpi_static_t> registered_static_variables_stack;
21 void smpi_register_static(void* arg, void_f_pvoid_t free_fn) {
22 s_smpi_static_t elm { arg, free_fn };
23 registered_static_variables_stack.push(elm);
26 void smpi_free_static() {
27 while (not registered_static_variables_stack.empty()) {
28 s_smpi_static_t elm = registered_static_variables_stack.top();
30 registered_static_variables_stack.pop();