- XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ", child->name_, parent->name_);
- xbt_dict_remove(parent->children_, child->name_);
- }
-}
-
-void PJ_container_free (container_t container)
-{
- if (container == nullptr){
- THROWF (tracing_error, 0, "trying to free a nullptr container");
- }
- XBT_DEBUG("destroy container %s", container->name_);
-
- //obligation to dump previous events because they might
- //reference the container that is about to be destroyed
- TRACE_last_timestamp_to_dump = surf_get_clock();
- TRACE_paje_dump_buffer(1);
-
- //trace my destruction
- if (not TRACE_disable_destroy() && container != PJ_container_get_root()) {
- //do not trace the container destruction if user requests
- //or if the container is root
- LogContainerDestruction(container);
- }
-
- //remove it from allContainers data structure
- xbt_dict_remove(allContainers, container->name_);
-
- //free
- xbt_free(container->name_);
- xbt_free(container->id_);
- xbt_dict_free(&container->children_);
- xbt_free (container);
- container = nullptr;
-}
-
-static void recursiveDestroyContainer (container_t container)
-{
- if (container == nullptr){
- THROWF (tracing_error, 0, "trying to recursively destroy a nullptr container");
- }
- XBT_DEBUG("recursiveDestroyContainer %s", container->name_);
- xbt_dict_cursor_t cursor = nullptr;
- container_t child;
- char *child_name;
- xbt_dict_foreach (container->children_, cursor, child_name, child) {
- recursiveDestroyContainer (child);
- }
- PJ_container_free (container);
-}
-
-void PJ_container_free_all ()
-{
- container_t root = PJ_container_get_root();
- if (root == nullptr){
- THROWF (tracing_error, 0, "trying to free all containers, but root is nullptr");
- }
- recursiveDestroyContainer (root);
- rootContainer = nullptr;
-
- //checks
- if (not xbt_dict_is_empty(allContainers)) {
- THROWF(tracing_error, 0, "some containers still present even after destroying all of them");