From 2739834206f23833161898a73427b8a9c6d5d26d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 28 Dec 2012 19:26:59 +0100 Subject: Add code to allow for late memory cleanup. * common/init.c (mem_cleanup_item_t): New. (run_mem_cleanup): New. (_init_common_subsystems): Add an atexit for it. (register_mem_cleanup_func): New. * g10/kbnode.c (cleanup_registered): New. (release_unused_nodes): New. (alloc_node): Call register_mem_cleanup_func. -- It is often time consuming to figure out whether still allocated memory at process termination is fine (e.g. a cache) or a problem. To help for that register_mem_cleanup_func may now be used to cleanup such memory. The run time of the program will be longer; if that turns out to be a problem we can change the code to only run in debugging mode. --- common/init.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/init.h') diff --git a/common/init.h b/common/init.h index 633ffac52..eea2eb167 100644 --- a/common/init.h +++ b/common/init.h @@ -36,6 +36,8 @@ # error GPG_ERR_SOURCE_DEFAULT has default value #endif +void register_mem_cleanup_func (void (*func)(void)); + void _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp); #define init_common_subsystems(a,b) \ -- cgit v1.2.3