18dffb485Schristos /* Cleanup routines for GDB, the GNU debugger. 28dffb485Schristos 3*5ba1f45fSchristos Copyright (C) 1986-2024 Free Software Foundation, Inc. 48dffb485Schristos 58dffb485Schristos This file is part of GDB. 68dffb485Schristos 78dffb485Schristos This program is free software; you can redistribute it and/or modify 88dffb485Schristos it under the terms of the GNU General Public License as published by 98dffb485Schristos the Free Software Foundation; either version 3 of the License, or 108dffb485Schristos (at your option) any later version. 118dffb485Schristos 128dffb485Schristos This program is distributed in the hope that it will be useful, 138dffb485Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 148dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 158dffb485Schristos GNU General Public License for more details. 168dffb485Schristos 178dffb485Schristos You should have received a copy of the GNU General Public License 188dffb485Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 198dffb485Schristos 208dffb485Schristos #include "cleanups.h" 21*5ba1f45fSchristos #include <vector> 228dffb485Schristos 23*5ba1f45fSchristos /* All the cleanup functions. */ 248dffb485Schristos 25*5ba1f45fSchristos static std::vector<std::function<void ()>> all_cleanups; 268dffb485Schristos 27*5ba1f45fSchristos /* See cleanups.h. */ 288dffb485Schristos 29*5ba1f45fSchristos void 30*5ba1f45fSchristos add_final_cleanup (std::function<void ()> &&func) 318dffb485Schristos { 32*5ba1f45fSchristos all_cleanups.emplace_back (std::move (func)); 338dffb485Schristos } 348dffb485Schristos 35*5ba1f45fSchristos /* See cleanups.h. */ 368dffb485Schristos 378dffb485Schristos void 388dffb485Schristos do_final_cleanups () 398dffb485Schristos { 40*5ba1f45fSchristos for (auto &func : all_cleanups) 41*5ba1f45fSchristos func (); 42*5ba1f45fSchristos all_cleanups.clear (); 438dffb485Schristos } 44