Rewrite final cleanups

This patch rewrites final cleanups to use std::function and otherwise
be more C++-ish.
This commit is contained in:
Tom Tromey
2024-02-23 13:10:28 -07:00
parent cfe51255b8
commit 1eae7be116
5 changed files with 33 additions and 154 deletions

View File

@@ -188,15 +188,6 @@ progressfn (debuginfod_client *c, long cur, long total)
return 0;
}
/* Cleanup ARG, which is a debuginfod_client pointer. */
static void
cleanup_debuginfod_client (void *arg)
{
debuginfod_client *client = static_cast<debuginfod_client *> (arg);
debuginfod_end (client);
}
/* Return a pointer to the single global debuginfod_client, initialising it
first if needed. */
@@ -221,7 +212,10 @@ get_debuginfod_client ()
handlers, which is too late.
So instead, we make use of GDB's final cleanup mechanism. */
make_final_cleanup (cleanup_debuginfod_client, global_client);
add_final_cleanup ([] ()
{
debuginfod_end (global_client);
});
debuginfod_set_progressfn (global_client, progressfn);
}
}