diff options
author | G. Branden Robinson <g.branden.robinson@gmail.com> | 2022-06-27 19:58:44 -0500 |
---|---|---|
committer | G. Branden Robinson <g.branden.robinson@gmail.com> | 2022-07-01 20:31:12 -0500 |
commit | 49a27412d6e12a8219a125193f2d13fa2d044164 (patch) | |
tree | f657ab177a34afeea792cab04eefcec7b2e37d8e /src | |
parent | 76b1179d8388fb969a7df0180555ed98d84c8bcc (diff) | |
download | groff-git-49a27412d6e12a8219a125193f2d13fa2d044164.tar.gz |
src/preproc/html/pre-html.cpp (cleanup): Add.
* src/preproc/html/pre-html.cpp (cleanup): Add function to tidy
memory before exiting.
(main): Register aforementioned function with `atexit()`. Die if
registration fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/preproc/html/pre-html.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp index 3cd7b2ffb..0c4bb4af4 100644 --- a/src/preproc/html/pre-html.cpp +++ b/src/preproc/html/pre-html.cpp @@ -1742,6 +1742,11 @@ static bool do_file(const char *filename) return true; } +static void cleanup(void) +{ + free(const_cast<char *>(image_gen)); +} + int main(int argc, char **argv) { #ifdef CAPTURE_MODE @@ -1757,6 +1762,8 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); #endif /* CAPTURE_MODE */ program_name = argv[0]; + if (atexit(&cleanup) != 0) + sys_fatal("atexit"); int operand_index = scanArguments(argc, argv); image_gen = strsave(get_image_generator()); if (0 == image_gen) |